-
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
Post Editor: Always force iframe in pattern editor #65887
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +21 B (0%) Total Size: 1.81 MB
ℹ️ View Unchanged
|
Flaky tests detected in c82a629. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11189817035
|
I agree this should be fixed. It’s great you spotted the bug.
It’s not clear to me why the conditions can’t already be aggregated there. The hook already checks the post type. I guess maybe the idea is that the hook is Post editor specific yet we want the change to apply in any editor? However for the Site editor it doesn’t seem possible for the canvas to not be iframed. In the widgets editor it seems pattern insertion isn’t allowed so pattern editing is also not possible. |
I've tried consolidating all the conditions into the
That's a good point. The widget editor doesn't allow us to create patterns from blocks. Even if you copy and paste a sync pattern from the post editor, it doesn't do anything because Perhaps there are hurdles to overcome before we can add patterns to the widget editor. Related issues: |
This reverts commit 5da8433.
The E2E test failure does not appear to be caused by the integration. I will try restoring the commit again at a later date. Update: The test failure was fixed in #65939, so I committed the condition integration again. |
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 updates. This looks like it’s on the right track.
const shouldIframe = | ||
! disableIframe || [ 'Tablet', 'Mobile' ].includes( deviceType ); |
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.
When I first commented, I wasn’t understanding you meant to remove the conditions here but it does make sense to me now. Still, it looks like the tablet and mobile conditions got left out of the post editor’s useShouldIframe
hook. I tested and the device previews weren’t working from a non-iframe starting point.
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.
Sorry, in my repeated commits I seem to have forgotten to update the useShouldIframe
hook. It should work as expected now.
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’ve tested again and it works as expected. There’s a conflict that popped up thanks to #66141 but it looks like it should be a straightforward resolution so I’m green lighting this anyway.
Thanks for the review! The conflict has been resolved. |
* Post Editor: Always force iframe in pattern editor * Aggregate conditions into useShouldIframe hook * Revert "Aggregate conditions into useShouldIframe hook" This reverts commit 5da8433. * Aggregate conditions into useShouldIframe hook * Add device type check to useShouldIframe check Co-authored-by: t-hamano <[email protected]> Co-authored-by: stokesman <[email protected]>
Noticed this while reviewing #65885
What?
In the post editor, force the pattern editor to always be an iframe, regardless of whether the main editor is an ifarme or not. This will make the pattern editor's height fit its content.
Why?
Whether the pattern editor in the post editor is an iframe or not is determined by whether the main editor is an iframe or not.
However, the pattern editor is a resizable editor and the editor height is expected to fit the content. Additionally, the padding appender (the functionality that adds a new block when you click below the last block) is not expected to be used with the pattern editor.
Therefore, if the main editor is not an iframe, clicking below the content in the pattern editor does nothing.
How?
Add a post type check.
However, changing the conditions that determine if it should be an iframe in a lower component (
VisualEditor
) may not be ideal - whether it should be an iframe or not is something the post editor should only care about. In the future, it may be possible to aggregate these conditions at a higher layer (useShouldIframe()
hook).Update: I consolidated all the conditions that determine whether to run an iframe or not into the useShouldIframe hook.
Testing Instructions