-
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
Lighter block DOM: contextual toolbar in popover #18779
Conversation
I love the purpose of this PR. Outside of making the DOM simpler (which vastly simplifies block editor block styling), it solves numerous issues where the toolbar is cropped in nested contexts, or just weirdly offset to the right. This is not counting all the other benefits you mention. If we could get the PR to a state where basically everything looks the same in the branch as it does in master, just with cleaner DOM, this would be great to ship. Future improvements could inform efforts in #18667. |
Right, I'll work on making everything look the same.
|
It does not necessarily need to be 100% accurate, and please let me know if you'd like me to do some of the heavy CSS lifting. |
@jasmussen Thanks! I'm pretty sure I'll need your help to clean up the CSS. I'll let you know when it's otherwise done. |
Nice! One possible benefit of this change is that it could make #7962 easier to fix. Some things I've noticed on this branch (I know it's WIP; just posting to point them out):
|
b83464d
to
3c9b4e3
Compare
e522411
to
ef48862
Compare
I fixed drag and drop of blocks. |
What a journey! First:
... and then shortly after:
You should get a medal. 🥇 |
@jasmussen Turned out one line was blocking drag 😅 |
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.
Let's try it. I'm still not very confident with the SlotFill changes. I'd rather find a way to avoid these.
a2081c9
to
463a981
Compare
There's a small remaining glitch with the toolbar that only happens in Chrome in some conditions. It happens when the content area is an odd number of pixels and as a result, in Chrome only, the reported block position and actual position have a difference of half a pixel, causing the toolbar position to be off by half a pixel. |
a3d4914
to
17c8ead
Compare
17c8ead
to
2c345a5
Compare
b8ebb3d
to
3bd6f07
Compare
Okay, I took everything for a last round of testing. I ensured that:
If I missed anything, I’ll fix it in a follow-up PR. To recap, this PR puts the block controls (contextual toolbar and movers) in a popover.
This PR introduces some unstable props on |
f6d700a
to
9830ff9
Compare
Congrats on getting this merged in @ellatrix — super excited to see what kinds of improvements this unlocks! 👏 |
} | ||
|
||
.block-editor-block-contextual-toolbar[data-align="full"] { | ||
margin-left: 0; |
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.
@ellatrix do you know why we need this? With G2 it's causing a bug (can't click the movers) but I'm not sure if it's needed for something else.
One of the unfortunate consequences of this change is that attempting to scroll the page while the cursor is atop the block toolbar will not scroll the block list. It's because the DOM hierarchy of the toolbar is no longer the same as the block list. In others instances, it might be the sort of thing we could use If I recall correctly, this implementation had customized where the slot rendered in the page. Is that right? Is it the sort of thing where we can be more intentional with rendering it as part of the scrollable block list, in order to address the issue? |
It's intentionally outside the scrollable container, so maybe in the future it can be unified with the top toolbar and so maybe the scrollable container can be iframed. Of course it's not nice that you cannot scroll while over a toolbar... :/ I can't immediately think of a solution. |
Worth also noting that since the introduction of the first "popover" implementation, the accessibility team feedback pointed out it's a pattern that's far from ideal for accessibility. We always pointed out that parts of the UI that "appear" after some user action should be in close proximity in the DOM with the control that was activated. For example: click a button, a menu opens, the menu should be immediately after the button in the DOM. Keeping moving important UIs far, far, away in the DOM is far from ideal for accessibility, even if focus is programmatically handled. Add to that this is also breaking a native, fundamental, browser feature like scrolling a page and it is pretty obvious any accessibility specialist can't support this change. |
Description
Edit: I decided to break this down in more steps, so this PR now only focuses on the contextual toolbar.
Fixes #7962.
This PR tries to use the
Popover
component for the contextual toolbar and breadcrumb (navigation mode).Why?
data-align
attribute).tagName
. For example, the image block could set it tofigure
, and a table block totable
.We already use
Popover
for a lot of UI (dropdown, inline toolbar, tooltips...), and the component continues to get better. For this PR, we'll need to make some adjustments to it so that the controls position correctly.How has this been tested?
Screenshots
Types of changes
Checklist: