-
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
Popover: Fix iframe story and add test #53182
Conversation
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.
Thank you for working on this! I saw a few odd things happening in my testing.
In Chrome, I see that the popover disappears as soon as I start to scroll within the container:
But I believe it should stay open until dismissed? And in Firefox, it starts out of view, and the popover can be scrolled, but the container cannot:
The container iframe titled 'My iframe' is empty in FF (it doesn't contain any elements in the body):
Vs Chrome:
The max-height
of the popover also varies between them (30px
in FF, 178px
in Chrome)
Flaky tests detected in 3ec5c25. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5739400949
|
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.
Testing this was odd for me. In the PR's current state (after the FF fix in 3ec5c25), Firefox looks great, but Chrome now fails to render any content inside the iframe for me. It looks very similar to what @brookewp reported in FF before that fix was added:
Chrome, with the FF fix applied
Chrome markup with the FF fix applied
If I drop that one commit, Chrome works again, (FF of course doesn't). I did notice the popover overlays the container's border when scrolling:
Scrolling within the container on Chrome, WITHOUT the Firefox fix
I've tested multiple times, but it feels weird to me that the FF fix would break Chrome... it's possible there's something funky happening locally for me if this isn't reproducible by others 🤔
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.
I tried this in Chrome and Orion and saw the same as Chad reported. I took a guess that adding a srcDoc
might somehow help. That seemed to do the trick and it started working in those browsers. Firefox remained okay too.
Thanks for testing everyone! And especially @stokesman for figuring out a fix 🙏 I actually couldn't reproduce this Chrome issue even with a hard refresh, but an Incognito tab somehow made it happen 😅 Should be working in all three browsers now.
I believe this is the expected behavior for the original story, because the popover content is being rendered in a slot outside of the purple border 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.
Looks 🚢 shape to me.
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.
😆
What?
Fixes the "With Slot Outside Iframe" story of the Popover component in Storybook.
I also added a unit test to ensure that the cross-document rendering is working as expected. This test is also a good first step in unblocking our version-pinned
floating-ui
dependency (#48402).Why?
This story was originally (#42903) written using the
Iframe
component in@wordpress/block-editor
. In #46706, there was an implementation change in thisIframe
component that introduced some conditional rendering logic that relied on the block editor store. This change broke the isolated example in Storybook, and made theIframe
component unsuitable for non-WP usage.How?
I replaced the
Iframe
component with a generic iframe component that is suitable for isolated testing.Testing Instructions
✅ Tests pass
npm run storybook:dev
Screenshots or screencast
Expected story
CleanShot.2023-08-05.at.02.57.04.mp4