-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try: Refactor appender margin. #33088
Conversation
Size Change: +739 B (0%) Total Size: 1.05 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/block-editor/src/components/block-list-appender/style.scss
Outdated
Show resolved
Hide resolved
6e25eb2
to
86364cc
Compare
I forced in the naive hope that would cause the buttons validation test to pass, but I don't think it's been fixed in trunk yet, so this one will likely end up red again. |
} | ||
|
||
// Cancel any left margin if the black plus is the only child. | ||
&:first-of-type .block-list-appender__toggle { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand this part, I might be missing some context. Why will it be the only child if it matches :first-of-type
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent question, thanks for calling it out.
first-of-type
is used because the appender is not the first-child
in an otherwise "empty" navigation block:
Shown here with zero width is an actual placeholder state for the navigation block. That placeholder state exists here but has zero with so that it can ensure the height of the navigation block is the same between the empty state, and when there are menu items inside, ensuring no layout shift when you insert.
Observe here in the top right corner that the margin-left: 0;
rule is correctly applied to the appender when the first-of-type
rule hits the target:
Here, it's no longer the first-of-type
, after a menu item has been inserted, and the 8px left margin applies:
That same rule applies here as well:
As noted in #33087 (comment), I think ultimately we need to remove the black plus from the editing canvas entirely, make it a popover that exists outside the canvas/iframe and is positioned in a way that doesn't cause layout shifts. That will be an opportunity to tear out all these complex rules.
In the mean time, I will add a comment to elaborate on why first-of-type is used. Sound good?
@jasmussen We should include this in Gutenberg 11.0.0 release. Could you ping me when merged? Much appreciated. |
Thanks everyone! |
* Try: Refactor appender margin. * Expand comment. * Add clarifying comment.
* Try: Refactor appender margin. * Expand comment. * Add clarifying comment.
* Try: Refactor appender margin. * Expand comment. * Add clarifying comment.
Description
Fixes #33085. Alternative to #33087.
As detailed in #33087 (comment), there's a small explicit left margin on the black appender plus, and an intentional right auto margin, so as to work inside flex containers:
It has to have an explicit left margin that isn't "auto", in order to work inside flex containers:
The problem as reported is that this left margin is applied also to the big white square plus, the "button" appender, and it shouldn't be.
This PR tries to move the margin from the general block appender itself (both black and white), to the specific button type inside (either black or white), thus solving the problem.
How has this been tested?
But it's also important to test this doesn't regress any of the other appenders in any of the contexts.
Checklist:
*.native.js
files for terms that need renaming or removal).