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 6 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
16 changes: 11 additions & 5 deletions packages/edit-post/src/components/layout/use-should-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export function useShouldIframe() {
const {
isBlockBasedTheme,
hasV3BlocksOnly,
isEditingTemplate,
isEditingTemplateOrPattern,
isZoomOutMode,
deviceType,
} = useSelect( ( select ) => {
const { getEditorSettings, getCurrentPostType } = select( editorStore );
const { getEditorSettings, getCurrentPostType, getDeviceType } =
select( editorStore );
const { __unstableGetEditorMode } = select( blockEditorStore );
const { getBlockTypes } = select( blocksStore );
const editorSettings = getEditorSettings();
Expand All @@ -24,15 +26,19 @@ 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',
deviceType: getDeviceType(),
};
}, [] );

return (
hasV3BlocksOnly ||
( isGutenbergPlugin && isBlockBasedTheme ) ||
isEditingTemplate ||
isZoomOutMode
isEditingTemplateOrPattern ||
isZoomOutMode ||
[ 'Tablet', 'Mobile' ].includes( deviceType )
);
}
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 @@ -360,8 +360,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 @@ -386,7 +384,7 @@ function VisualEditor( {
{
'has-padding': isFocusedEntity || enableResizing,
'is-resizable': enableResizing,
'is-iframed': shouldIframe,
'is-iframed': ! disableIframe,
}
) }
>
Expand All @@ -397,7 +395,7 @@ function VisualEditor( {
}
>
<BlockCanvas
shouldIframe={ shouldIframe }
shouldIframe={ ! disableIframe }
contentRef={ contentRef }
styles={ iframeStyles }
height="100%"
Expand Down
Loading