-
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
Embed block: Fix inline preview cut-off when editing URL #35326
Conversation
Size Change: +45 B (0%) Total Size: 1.23 MB
ℹ️ View Unchanged
|
Looks like some of the e2e tests defined in Expected:
Received:
I'll investigate this issue further and provide a solution as soon as possible 💨 . |
I've addressed this issue in this commit 🔧 . |
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 these changes @fluiddot Tested and verified that the cut-off issue is no longer present. LGTM 🚢
Hi folks, Is this PR good to merge? Maybe rebase just to be certain tests are still passing. |
057e7bb
to
de7db7d
Compare
I've just rebased with Before considering merging the PR, I'd appreciate having another review since this change affects the web version. @Mamaduka I'm wondering if you would be able to take a look, thanks for the help 🙇. |
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.
It works as expected. Thanks, @fluiddot.
* Use empty classname when handling incoming preview * Force sandbox render when type prop changes * Add ignore previous classname option to merged attributes * Move get merged attributes function to util class
Description
This PR changes the calculation of attributes when handling an incoming preview after editing the URL of an embed block. Previously, the attributes were obtained from the
getMergedAttributes
function, however, this function could return the classname from the previous embed, which depending on the new embed could lead to rendering issues, as the cut-off mentioned in wordpress-mobile/gutenberg-mobile#4059.These rendering issues are caused when the previous embed adds the aspect ratio classes to the classname attribute, then after setting a different URL, the new embed expects to have that attribute empty. In the following code references, you can see the flow of how the classname is calculated when handling an incoming preview:
gutenberg/packages/block-library/src/embed/edit.native.js
Line 184 in c357fc7
gutenberg/packages/block-library/src/embed/edit.native.js
Lines 137 to 143 in c357fc7
gutenberg/packages/block-library/src/embed/util.js
Lines 243 to 260 in c357fc7
gutenberg/packages/block-library/src/embed/util.js
Lines 284 to 288 in c357fc7
gutenberg/packages/block-library/src/embed/util.js
Lines 177 to 227 in c357fc7
The calculation is now done in a similar way as the
getMergedAttributes
function but passing an empty classname ingetAttributesFromPreview
. This way we assure that the classname attribute set to the block doesn't preserve the value from the previous embed.This change also required updating the side-effects of the
Sandbox
component that updates the HTML of the iframe. When thetype
prop is modified (this prop is used to pass the classname), we need to force rendering the HTML of the iframe so it renders the proper aspect ratio styles.How has this been tested?
Screenshots
embed-block-cutoff-issue-before.mp4
embed-block-cutoff-issue-after.mp4
Types of changes
Bug fix
Checklist:
*.native.js
files for terms that need renaming or removal).