-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Try: Hide the columns inserter in pattern previews. #36626
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
Conversation
|
|
||
| // Hide inserter from previews. | ||
| // This selector could be cleaner if we had a CSS class to target inside the preview iframe. | ||
| html[style] body > .is-root-container .wp-block-columns { |
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.
😅 Yeah, that's a weird stack of selectors. It would be way better if there were a more specific class we could tie into for the preview frame.
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.
It didn't feel right, so I just tried to push one that features a classname. But now I'd prefer a developer review of this one as well.
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.
👍 Yeah, this new one feels much better.
|
Size Change: -3.21 kB (0%) Total Size: 1.1 MB
ℹ️ View Unchanged
|
|
|
||
| // Hide inserter from previews. | ||
| .block-editor-block-preview__content-iframe .wp-block-columns .block-list-appender { | ||
| display: none; | ||
| } |
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.
Is there a reason this is being added to the styles of the long-deprecated Text Columns block and not the Columns block?
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.
Yes! The reason is I was moving too fast. Ack. I'll address this and Carolina's feedback below.
|
I think the inserter should always be hidden in the preview, is the columns block the only block where it shows? |
|
Pushed a fix that removes it from text-columns (🙈) and adds it to the generic preview component styles. What do you think about the iframe class I added? |
|
The new CSS is simpler -are there any known third party implementation (custom blocks?) concerns? |
Not that I can think of, unless a 3rd party block leverages classname called |
|
Is this close enough to land? |
kjellr
left a comment
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.
This works well, and seems simple enough. Thanks, @jasmussen!
| Before | After |
|---|---|
![]() |
![]() |
|
Cool, let's try this, and it's always easy to follow up. |
| } | ||
|
|
||
| // Hide inserter from previews. | ||
| .block-editor-block-preview__content-iframe .block-list-appender { |
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.
We already have a lot of similar styles above, why didn't we just nest this in .block-editor-block-preview__container above? instead of adding this new class?
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 guess the fact that we introduced iframes for previews is preventing all these resets from applying, in that case, maybe we should move all these reset styles inside the iframe selector. cc @ellatrix
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'm happy to try a followup here. But from what I can tell, we actually do need both the outer and the inner container. The outer sets things like border, border radius, pointer cursor, all unscaled. The inner is only for content inside the iframe, and as you found, needs to be unscoped.
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.
Ideally we should be able to render a block list in a disabled mode that doesn't render any appenders. I thought we actually already did that because other appenders didn't show before in the preview.
* Try: Hide the columns inserter in pattern previews. * Try a classname instead. * Address feedback.


Description
Fixes #36625. This adds a rule to the columns block editor stylesheet to hide the inserter when seen inside the preview iframe:
For now this is a small PR that fixes it for the columns block, which seems to be the primary offender. The PR could be refactored by adding a small CSS class to the preview component, so the selector to target only the contents of the preview could be simplified. (If you see this and feel lucky, you can push directly to this branch if you like.)
How has this been tested?
Try opening the inserter and going to patterns, you should see no inserter in the Forest pattern as shown.
Checklist:
*.native.jsfiles for terms that need renaming or removal).