-
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
Fix global style variations previews not showing correct height #39737
Conversation
@@ -91,7 +91,7 @@ const StylesPreview = ( { label, isFocused } ) => { | |||
{ containerResizeListener } | |||
<motion.div | |||
style={ { | |||
height: '100%', | |||
height: 150 * ratio, |
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 matches the height set on the iframe on line 84. Reviewers might need to expand the file to see it.
Size Change: -4 B (0%) Total Size: 1.21 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.
This looks good to me, thanks for following up @talldan! Also fixes the larger preview, too:
Before | After |
---|---|
From your comment on #39725 (comment) — it sounds like we might still want both PRs if that one makes the test a bit more reliable?
Related and potential alternative to #39725
What?
Should help fix the failing tests in
trunk
. This seems to have started happening after #38855 was merged.Why?
From what I can tell, now that the previews are rendering using standards mode instead of quirks mode, there's a change to how the document in the iframe determines its size. Previously it assumed the size of the iframe (like having
height: 100%
), but now it assumes the size of the content (like havingheight: auto
).The problem with this is not only did the previews end up looking wrong, but there was also a problem where the bottom part of the preview couldn't be clicked (the cause of the e2e test failures—props to @Mamaduka for diagnosing that).
How?
I've fixed it by giving the content an explicit height that matches the iframe's height.
I'm not all that familiar with the code, so unsure if there are issues with this fix. It looks like content in the iframe is all known ahead of time rather than dynamic, so I wouldn't expect any problems.
Testing Instructions
Use a theme that has style variations. The gutenberg test environment has one called 'Style Variations'.
Screenshots or screencast
Before
After