-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Popover: remove custom frame scroll/resize listeners #54286
Conversation
Flaky tests detected in af40356. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6119114278
|
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 is a neat cleanup 👍 Hope the floating-ui
PR will land soon!
af40356
to
b5f24e2
Compare
b5f24e2
to
88e3895
Compare
Size Change: -218 B (0%) Total Size: 1.52 MB
ℹ️ View Unchanged
|
The How to test:
|
88e3895
to
02b5e9f
Compare
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 tests well according to the testing instructions above 👍
Cool cleanup too!
I'll leave the final 👍 to @ciampo.
I was just curious - should there be a reliable way to test this in storybook too?
Floating UI has "visual" tests, and for my patch I added only a unit test. A visual test where you can test that it really works in a real browser could be a useful follow-up. In Gutenberg's storybook? I'm not sure, we currently don't have any stories for iframes explicitly, do we? |
We seem to have at least one: https://wordpress.github.io/gutenberg/?path=/story/components-popover--with-slot-outside-iframe |
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.
Code is nice and clean, and the changes test well as per instructions.
I also tested briefly in Storybook (the story that @tyxla linked above) and things seems to work well as on trunk
— ie. the popover is placed correctly only when the toolbar and the sidebar are hidden. I'd be curious to know why that is still the case and if we could make further improvements in floating UI (maybe look recursively for ancestors that are more than one level up the hierarchy?), although definitely not a blocker.
popover.iframe.test.mp4
Thanks for pointing this out, the popover is really quite broken in the storybook. I'll try to find out why. |
It's happening because the iframe offset is taken into account only when calculating the client rect for the reference (anchor) element, but not for the floating (popover) element. In Gutenberg only the anchor element is ever in an iframe, the popover is always in the top document. So the bug is not visible. But Storybook renders the entire story, with all elements, inside a "preview iframe". That iframe has an offset that is not applied to the popover element, only the anchor. I'm now going to merge this PR because it's not really related to this situation. We should expand the iframe story to also include the case when the iframe's parent element is scrolling, but let's do it in a different PR, after the positioning gets fixed. If we did it now, we'd be testing something that's already broken. |
Agreed 100% with your opinion and your suggested next steps. Thank you! |
Also noting that Tooltips (using ariakit, and therefore floating UI) are currently facing the same issue in Storybook https://wordpress.github.io/gutenberg/?path=/story/components-tooltip--default |
After Floating UI ships a fix for iframe support in
getOverflowAncestors
(my WIP PR is here: floating-ui/floating-ui#2535), we'll be able to remove a lot of custom code fromPopover
, code that finds the iframe of the reference and floating elements and attachesresize
andscroll
listeners to the iframe parent.This is a draft PR that works together with the Floating UI changes, and is useful for testing that the changes really work.
It will remain a draft until we can really upgrade to a fixed version of Floating UI.