Skip to content
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

Merged
merged 7 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/edit-post/src/components/layout/use-should-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function useShouldIframe() {
const {
isBlockBasedTheme,
hasV3BlocksOnly,
isEditingTemplate,
isEditingTemplateOrPattern,
isZoomOutMode,
} = useSelect( ( select ) => {
const { getEditorSettings, getCurrentPostType } = select( editorStore );
Expand All @@ -24,15 +24,17 @@ export function useShouldIframe() {
hasV3BlocksOnly: getBlockTypes().every( ( type ) => {
return type.apiVersion >= 3;
} ),
isEditingTemplate: getCurrentPostType() === 'wp_template',
isEditingTemplateOrPattern: [ 'wp_template', 'wp_block' ].includes(
getCurrentPostType()
),
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
};
}, [] );

return (
hasV3BlocksOnly ||
( isGutenbergPlugin && isBlockBasedTheme ) ||
isEditingTemplate ||
isEditingTemplateOrPattern ||
isZoomOutMode
);
}
6 changes: 2 additions & 4 deletions packages/editor/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,6 @@ function VisualEditor( {
! isMobileViewport &&
// Dsiable resizing in zoomed-out mode.
! isZoomedOut;
const shouldIframe =
! disableIframe || [ 'Tablet', 'Mobile' ].includes( deviceType );
Comment on lines -363 to -364
Copy link
Contributor

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.

Copy link
Contributor Author

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.


const iframeStyles = useMemo( () => {
return [
Expand All @@ -384,7 +382,7 @@ function VisualEditor( {
{
'has-padding': isFocusedEntity || enableResizing,
'is-resizable': enableResizing,
'is-iframed': shouldIframe,
'is-iframed': ! disableIframe,
}
) }
>
Expand All @@ -395,7 +393,7 @@ function VisualEditor( {
}
>
<BlockCanvas
shouldIframe={ shouldIframe }
shouldIframe={ ! disableIframe }
contentRef={ contentRef }
styles={ iframeStyles }
height="100%"
Expand Down
Loading