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

Zoom out: Disable 'Desktop (50%)' option in the non-iframed editor #64264

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packages/editor/src/components/editor-interface/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export default function EditorInterface( {
forceDisableBlockTools={ forceDisableBlockTools }
title={ title }
icon={ icon }
disableIframe={ disableIframe }
/>
)
}
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function Header( {
setEntitiesSavedStatesCallback,
title,
icon,
disableIframe = false,
} ) {
const isWideViewport = useViewportMatch( 'large' );
const isLargeViewport = useViewportMatch( 'medium' );
Expand Down Expand Up @@ -136,6 +137,7 @@ function Header( {
<PreviewDropdown
forceIsAutosaveable={ forceIsDirty }
disabled={ isNestedEntity }
disableIframe={ disableIframe }
/>
<PostPreviewButton
className="editor-header__post-preview-button"
Expand Down
12 changes: 9 additions & 3 deletions packages/editor/src/components/preview-dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as editorStore } from '../../store';
import PostPreviewButton from '../post-preview-button';

export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
export default function PreviewDropdown( {
forceIsAutosaveable,
disabled,
disableIframe = false,
} ) {
const {
deviceType,
editorMode,
Expand Down Expand Up @@ -111,7 +115,9 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
label: __( 'Desktop' ),
icon: desktop,
},
{
// The "Desktop (50%)" option only works in the iframe editor,
// so disable it in the non-iframe editor.
! disableIframe && {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zoom-out should generally be disabled if there's no iframe

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to get this value of disableIframe without passing it down in props?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might also need to disable the experimental zoomed-out view when the pattern category is selected and the editor is not an iframe, otherwise we'll be forcing "Desktop (50%)" even though it's not in the view options:

8ac90c830538f13f8d330a5810987d3b.mp4

Perhaps we need to know whether the editor is an iframe or not here, is there a way?

value: 'ZoomOut',
label: __( 'Desktop (50%)' ),
icon: desktop,
Expand All @@ -126,7 +132,7 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
label: __( 'Mobile' ),
icon: mobile,
},
];
].filter( Boolean );

const previewValue = editorMode === 'zoom-out' ? 'ZoomOut' : deviceType;

Expand Down
Loading