-
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
Block Toolbar Regression - Toolbar obstructs selected blocks. #41575
Comments
Any thoughts or work to resolve this issue? This seems like it should be high priority. Every block in short height Headers in the site editor suffers from this toolbar overlapping it - logos, site titles, taglines, navigation, etc... |
This is a regression. I will flag in the Core Editor chat to get it some more 👀 |
I'll see if I can work this one out |
There are notably quite a few popover issues that may be related, or even the same bug - #42058, #41823, #41739. After bisecting, this particular one does seem to be caused by #40740. I'm assuming there's supposed to be some logic to flip the toolbar to underneath the block that's missing. edit: looks like it's this bit (thanks to whoever left the comments): gutenberg/packages/components/src/popover/utils.js Lines 197 to 229 in b499487
another edit: I'm guessing the above code will need to be converted to a floating-ui middleware. The |
I tried a fix in #42086, but unfortunately that PR currently regresses another part of the toolbar positioning. I'll continue looking for a solution. |
I can also confirm that #40470 introduced the regression.
On top of this logic, another interesting change is that #40470 removed the gutenberg/packages/block-editor/src/components/block-popover/index.js Lines 76 to 78 in b99e668
The way I see it, the
That seems like a good idea — in general, I'd love to implement a solution that works regardlessly of where the Looking at the code, the
I started tinkering and noticed another prop called gutenberg/packages/components/src/popover/index.js Lines 201 to 207 in fe4890f
I ended up removing the two mentioned props: diff --git a/packages/block-editor/src/components/block-popover/index.js b/packages/block-editor/src/components/block-popover/index.js
index 370959d1b1..74cefd54dd 100644
--- a/packages/block-editor/src/components/block-popover/index.js
+++ b/packages/block-editor/src/components/block-popover/index.js
@@ -61,8 +61,8 @@ export default function BlockPopover( {
__unstableSlotName={ __unstablePopoverSlot || null }
// Observe movement for block animations (especially horizontal).
__unstableObserveElement={ selectedElement }
- __unstableForcePosition
- __unstableShift
{ ...props }
className={ classnames(
'block-editor-block-popover', and it looks like these changes may be going in the right direction (although I have no context on why these props existed in the first place (maybe they can be removed?), and I haven't really checked for other regressions): Kapture.2022-07-12.at.14.37.50.mp4 |
@ciampo To restore the behavior that was in place before it should work a bit like this (using floating-ui terminology):
What you mentioned here is one of the difficulties with implementing a fix. There doesn't seem to be a way to restore the previous functionality within the Popover component itself. I think writing custom middleware is the only way to fix the regression, and it would need to be external to the Popover component in BlockPopover. |
I have something that I think works as expected now in #42086. Turns out that I didn't need the |
Noting that site editor(iframe) has different handling/nuances from the post editor we need to take into account. The scroll update is an example. |
There is existing middleware that offsets the iframe position so that later middleware already has that offset: gutenberg/packages/components/src/popover/index.js Lines 161 to 182 in f01f981
I didn't notice any differences between the site editor and post editor, but let me know if you spot anything. |
I'm not understanding exactly what is the expected behavior — in particular this point here:
Here's my reasoning: if, when there's not enough space at the top of the editor canvas, the popover flips (and therefore moves below the block), why does it also need to shift? The flip should already fix the "not enough space at the top" issue. I checked out commit b499487 (the one immediately before the Kapture.2022-07-13.at.17.27.03.mp4I don't have much context around the behavior of the toolbar's |
@ciampo It seems as though the shift behavior I described happens in the post editor. Try the Gutenberg Demo post as the easiest way to test: Kapture.2022-07-14.at.10.05.10.mp4That's the way it has worked for quite a while. The |
As stated before, I am not experience in working on the site editor or the post editor, and I'm not very experience with the
WDYT? |
I did some more delving. The root cause of the difference is the site editor using an iframe and a different scroll container for content. In the site editor, the blocks are inside the iframe and the toolbar outside. The blocks are also inside a scroll container element, and the toolbar popover outside of that scroll container. When the content is scrolled, the toolbar popover isn't being scrolled with it, so its position has to be continuously updated on scroll: gutenberg/packages/components/src/popover/index.js Lines 320 to 328 in c8feb39
This is different to the post editor where the toolbar popover is within the scroll container and scrolls with the content, no positional update on scroll is required. I think Floating UI smoothes out some of these inconsistencies, but the code I wrote in #42086 doesn't. I know the post editor will at some point also use an iframe for its content, so there will be more consistency. Though there's still the widget editors to consider. Having said that, updating the toolbar position continuously on scroll like the site editor does seems like an expensive option, and it'll always prove to be a little laggy. It may be better to try changing the scroll container and make it more like the post editor—though I think this would mean dynamically sizing the iframe to its content, which is never easy. |
@Greatdane Yep, that one's a different issue/bug that happens because the submenus are overflowing the block container. #40382 is the correct issue that tracks it 👍 This one was a bug where any block at the top of the editor was overlapped. |
When a block is near the top of the canvas and selected, the block toolbar obstructs the block.
We previously resolved this in #29464 by moving the toolbar beneath the selected block IF there is no room in the editor canvas to position it above the block without selected block obstruction.
Some recent change has caused a regression in this behavior, trying to place the toolbar above the block regardless of available space. This causes the toolbar to float over the selected block, obstructing the user from interacting with that block or its children.
BEFORE REGRESSION:
AFTER REGRESSION (current trunk branch):
Either we need to:
The current state is extremely limiting and will not be acceptable to be in place for any extended period of time. Users are reporting inability to edit certain blocks near the top of the canvas, such as the main navigation block in their header.
cc @talldan @jasmussen @youknowriad @getdave @mtias
The text was updated successfully, but these errors were encountered: