-
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
Fix block settings dropdown positioning when scrolling in the site editor #43544
Conversation
…d update the popover on scroll of that document
Size Change: +191 B (0%) Total Size: 1.24 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.
Thanks for the PR Dan!
I started testing and it was interesting to see that the format popover is not positioned properly - haven't checked the code well yet..
Screen.Recording.2022-08-24.at.10.18.31.AM.mov
This is unexpected — I thought that, for the "second gen" popover, all that mattered was the position of its anchor (and therefore it would be unaffected by what happens in the Also, if the anchor and the popover are within the same document (which is the case for the settings dropdown), I also expected that |
Ah, I imagine it's a slot/fill thing. 🤔 |
I gave this PR a spin and noticed that:
Kapture.2022-08-24.at.11.17.28.mp4
I was hoping that some of these issues could be fixed by the different approach to
Maybe we need to tinker with the |
With #43617 merged, I believe we can close this PR. Feel free to re-open in case I was mistaken! |
What?
Fixes #42725
(best reviewed using the 'Hide whitespace' option)
Why?
To describe the bug requires a bit of background.
The site editor uses an iframe for its content, and all blocks are within the iframe.
Popovers are outside the iframe in the main document. Whenever the iframe is scrolled, popovers that are anchored to blocks (like the the block toolbar) listen for the scroll event and update their position on the screen to match where the block is. You have this situation:
This bug happens because the block settings menu dropdown is a nested popover. It's anchored to another popover (the block toolbar) that isn't in an iframe, so it doesn't know to listen for scroll events.
How?
I could only think of one feasible way to solve this bug, which is to add a context provider that stores the root (reference) document for nested popovers, allowing them to also listen for scroll events.
Testing Instructions
Expected: the toolbar and settings menu should stay anchored to the block
Screenshots or screencast
Before
Kapture.2022-08-24.at.15.00.34.mp4
After
Kapture.2022-08-24.at.14.58.18.mp4