Repository navigation
Add Boundary Mode to visualize block boundaries - #69388
Sukhendu2002 wants to merge 7 commits into
Conversation
|
Thanks for contributing, @Sukhendu2002! For issues like #66576, I recommend seeking feedback before moving on with the development. |
|
this mode need to be by default when editing like on elementor |
|
This is great. I strongly believe a toggle on/off outline or boundary is needed for complex page layouts. In older WP this was done with lots of psuedo elements to add borders around blocks and the UX was much better. However the downside was the extra markup and psuedo elements often conflicted with blocks that were using pseudo elements for some aspect of styling. Just today I'm fixing a content issue on multiple posts because a user didn't realize they nested a reusable block inside multiple group blocks and broke the layout due to styles attached to the group block. In the Editor it is nearly impossible for the typical user to understand what was wrong with the block structure because so many blocks are effectively invisible and they can't see them. Only someone experienced knows to look at the rendered HTML structure on the frontend or look at the block outline to decipher what was happening structurally. |
|
What's the next step to get this merged? |
|
Based on discussion, this mostly needs a branch refresh and a code review, as well as addressing the feedback given. I wonder how we can unstick this: @WordPress/gutenberg-core. |
|
Important Review skippedAuto reviews are disabled on this repository. To trigger a review, include ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
I have updated this PR to get a code review and design feedback. Personally, I find this feature useful and anticipate that many people will need it. @Sukhendu2002, do you have the bandwidth to continue working on this PR? |
ramonjd
left a comment
There was a problem hiding this comment.
Just a flyby review. I think this is a nice feature.
Looks like we need to be careful about how we overwrite block CSS as far as I can see.
e9aa2e2 to
2fc74d4
Compare
|
Thanks for the feedback, @ramonjd, @mtias, @jasmussen, and @t-hamano. I’ve rebased the PR onto the latest |
|
Thanks @Sukhendu2002 for continuously working on this! @jasmussen I have tested I'd also like to propose that the boundary is only shown when the user hovers the editor content, not the page list or inspector. Especially when changing borders and spacing, with the current implementation the user would need to disable and enable the boundary mode all the time to properly see their changes. My video from #66576 (comment) shows how this could look like. |
|
In #80578 there are some more borders incoming for blocks with notes. If this gets in 1st we need to recheck there cc @adamsilverstein |
t-hamano
left a comment
There was a problem hiding this comment.
with the current implementation the user would need to disable and enable the boundary mode all the time to properly see their changes.
What do you think about adding it not only to the Preferences modal, but also to the options menu? The View category should be a good fit. Furthermore, if #82976 adds a submenu, it should make things even cleaner.
Another thing I noticed is that outlines should probably be hidden in zoom-out mode, as the lines become thinner and users can only select section blocks in this mode anyway.
Yes, this is also a good idea, maybe even better than toggling the boundary mode only in the Appearance settings. There could be situations where a user left off their work and a few weeks later log back in, only because they want to do some minor design changes. Depending on how they left the editor, they need to enable the template view, edit the pattern, deactivate the boundary mode… this could be too much for many people. FYI @fcoveram, this discussion here might be relevant to you for #83102 |
Rename the preference, preserve block pseudo-elements, and hide boundaries in previews. Refs WordPress#66576
82665df to
46d1e0e
Compare
|
|
||
| // Display visible borders around all blocks to visualize their boundaries. | ||
| .show-block-boundaries .block-editor-block-list__block { | ||
| outline: 1px dashed color-mix(in srgb, var(--wp-admin-theme-color, #007cba) 60%, transparent); |
There was a problem hiding this comment.
I understand that the use of color-mix is intentional, but the outline might be difficult to see in some dark themes. There might still be room for improvement.
outline: 1px dashed color-mix(in srgb, var(--wp-admin-theme-color, #007cba) 60%, transparent);
outline: 1px dashed var(--wp-admin-theme-color, #007cba);
|
This worked well in my testing, nice one! |
|
Noting that I personally feel like it is a bridge too far to bring this toggle to the appearance flyout. I would keep this only in Preferences > Appearance, at least in the first PR. It is tempting to put it in the main ellipsis now that we have a dropdown, but it is also a temptation that can easily lead to it being a kitchen sink very quickly. I'm thinking also of #74546 which would exist to further simplify the whole thing. Not offering a blocker, but that's the only piece where I would pull this PR back. |
I don't have a strong preference either way, but I think starting small is a good approach. |
|
Let's get this in. I agree with @jasmussen about not placing it in the flyout menu yet. Should we consider placing this in the accessibility set of preferences instead of appearance? |
🤖 PR meta 🤖🎉 PropsUnlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @orionp13, @deutrino, @ajitbohra. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the |
…-mode # Conflicts: # packages/block-editor/CHANGELOG.md # packages/editor/CHANGELOG.md
|
Thanks for the feedback. I’ve updated the PR to:
The existing preference key and command remain unchanged. Ready for another look when you have time. |
| } | ||
|
|
||
| // Display visible borders around all blocks to visualize their boundaries. | ||
| .show-block-boundaries .block-editor-block-list__block { |
There was a problem hiding this comment.
| .show-block-boundaries .block-editor-block-list__block { | |
| .show-block-boundaries .block-editor-block-list__block:not(.is-editing-disabled) { |
While this may be open to debate, I believe block boundaries should only be displayed on blocks that are actually selectable and editable. For blocks within a template where clicking does nothing, their outlines should not be highlighted.
Before
After


What?
Closes: #66576
This PR adds a new "Boundary Mode" that helps users visualise block boundaries during editing.
Testing Instructions
Screenshots or screencast
Screen.Recording.2025-03-03.at.3.57.34.PM.mov