Skip to content

Editor HTML: Give #poststuff div a broader scope; remove unused #postbox-container-2#4697

Merged
youknowriad merged 7 commits intoWordPress:masterfrom
gthayer:update/html-cleanup
Feb 8, 2018
Merged

Editor HTML: Give #poststuff div a broader scope; remove unused #postbox-container-2#4697
youknowriad merged 7 commits intoWordPress:masterfrom
gthayer:update/html-cleanup

Conversation

@gthayer
Copy link
Copy Markdown

@gthayer gthayer commented Jan 26, 2018

Description

Removed some duplicate IDs which are printed in the metabox area.
This is somewhat in reference to #2375

How Has This Been Tested?

npm test

Screenshots (jpeg or gifs if applicable):

Types of changes

Gave #poststuff a broader scope as it wraps the entire editor in classic.
Removed #postbox-container-2 as it is not being used at all.

Checklist:

I believe I am all set with these items, but I'd appreciate some outside help

  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.

@danielbachhuber danielbachhuber changed the title Update/html cleanup Editor HTML: Give #poststuff div a broader scope; remove unused #postbox-container-2 Jan 31, 2018
Copy link
Copy Markdown
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this.

It could be a nice idea to rebase master because right now we can't really try this PR since the meta boxes are not showing up because of this #4773

Also, this breaks the design of the meta boxes because we're relying on #poststuff to style the meta boxes in /editor/components/meta-boxes/meta-boxes-area/style.scss. We should probably update these styles to rely on something else for specificity.

Might be good to test with some popular meta boxes plugin to see if there's no regressions compared to master.

@gthayer gthayer closed this Feb 6, 2018
@gthayer gthayer reopened this Feb 6, 2018
@gthayer
Copy link
Copy Markdown
Author

gthayer commented Feb 6, 2018

Tested style updates with ACF and Yoast. I've corrected any of the style issues related to this change within Gutenberg, however WP core is also using #poststuff in the style sheet. Currently, labels are displaying larger than they should be.

I'm not sure whether I should be overwriting core's styles whole cloth, or if this PR is something which should be reviewed later when Gutenberg is merged with core.

@youknowriad
Copy link
Copy Markdown
Contributor

Thanks for the updates @gthayer This is way better. And yes, let's "copy" these styles to make them work with the new selectors and once we merge we'd have to remove the useless styles from Core.

@gthayer
Copy link
Copy Markdown
Author

gthayer commented Feb 8, 2018

Added the styles for improved metabox labels. I did some more testing with ACF and other metabox plugins, and found a few more issues.

#poststuff is being used commonly in plugins for styling and JS calls, notably ACF's map field was no longer working. I raised #poststuff to be higher in the DOM so it better wraps the meta content.

In an effort to reduce styling based on ID, I've switched #poststuff css calls to .postbox. However, core is still overwriting the styles because IDs have a higher priority than classes. I've added a #poststuff wrapper to the style sheet to make sure the correct styles are displaying, which can easily be removed at a later date.

Lastly, metabox inputs had a max-width of 300px. This was breaking the display of some plugins. I don't see where this was adding any value, so I removed it.

#post {
margin: 0;
}
#post {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR but I believe this one is not necessary anymore, this is probably a leftover for some old PR.

Copy link
Copy Markdown
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work here, Thanks for addressing all the concerns

@youknowriad youknowriad merged commit e25a2a5 into WordPress:master Feb 8, 2018
@jasmussen
Copy link
Copy Markdown
Contributor

Moving the #poststuff class up higher in the hierarchy has caused CSS bleed into the editor:

poststuff

While I can increase the specificity and even rewrite the CSS rules for headings, @mtias only just discovered the h2 heading receiving the new styles. There could be a bunch of other stuff cascading into the editor.

Do we actually need the poststuff class there, or is there a different way to apply it so that metaboxes can inherit those styles, but without them bleeding into the editor?

@youknowriad
Copy link
Copy Markdown
Contributor

@jasmussen Unfortunately, we need it there because it has to contain all the meta boxes (content and sidebar) since we can't use an id twice. And this id is necessary for some meta boxes to work properly.

So if it's easy enough to override these styles, I think we should do it. If it takes a lot of time, we can revert this change temporarily while fixing those.

@mtias
Copy link
Copy Markdown
Member

mtias commented Feb 8, 2018

The problem is as soon as we start overwriting these styles with more specificty we are making it much harder for themes to supply their own styles. I really don't want to see #poststuff proliferate as a selector in ways we cannot easily undo.

@youknowriad
Copy link
Copy Markdown
Contributor

Maybe we're fine with not valid HTML in this case? (instead of breaking meta boxes)

@jasmussen
Copy link
Copy Markdown
Contributor

Is there a way we can find out how many, even ball-park, plugins that are affected by the previous configuration compared to this? And how hard would it be for those plugins to update to function in that configuration?

@gthayer
Copy link
Copy Markdown
Author

gthayer commented Feb 8, 2018

Would something like this work?

https://github.com/gthayer/gutenberg/commit/d35b16e3b4ae7342607a12f79a7eee998df59d12

This maintains the backwards compatibility for plugins, but "#poststuff" only wraps the metaboxs.

I did a quick search on one of my sites, and found that #poststuff is used by Gravity Forms, WooCommerce, ACF, and Jetpack.

@youknowriad
Copy link
Copy Markdown
Contributor

@gthayer This doesn't take the "side" meta boxes into account.

@jasmussen
Copy link
Copy Markdown
Contributor

Seems like it would be valuable to try and find out in slightly more detail what, specifically, metaboxes do with the #poststuff class. For example if we were to limit this class to only below-the-post metaboxes, how would that affect side metaboxes? Would there only be CSS issues?

I'm all for supporting metaboxes, but we have to try and find a balance between a clean and optimized codebase going forward, otherwise we are creating new technical debt.

@jasmussen
Copy link
Copy Markdown
Contributor

Also CSS bleed in the Cover Image:

screen shot 2018-02-09 at 07 54 46

youknowriad added a commit that referenced this pull request Feb 9, 2018
youknowriad added a commit that referenced this pull request Feb 9, 2018
@gthayer
Copy link
Copy Markdown
Author

gthayer commented Feb 9, 2018

I think part of the problem is #poststuff has a very high position in the classic editor's DOM and plugins are using it align their styles and templates with core. It's not specific to metaboxes alone.

I've looked into a few flagship plugins I use, and the usage appears somewhat consistent.

Advanced Custom Fields

  • Added as a wrapper to their options page
  • Added to CSS as a wrapper for Post Box
  • JavaScript events are initialized with #poststuff
  • Note: The PRO version is less reliant on #poststuff

BuddyPress

  • Added as a wrapper to their admin pages
  • No specific styles or JS events I see

Gravity Forms

  • Added as a wrapper for the entry details and results section
  • Minimal styling for margins

Jetpack

  • Added as a wrapper for the CSS Stylesheet Editor
  • Margin and padding based style edits for CSS editor and publicize.

@gthayer
Copy link
Copy Markdown
Author

gthayer commented Feb 9, 2018

One more:

WooCommerce

  • Added as wrapper for report admin pages
  • Margin, padding, and border based style edits for sidebar metaboxes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants