-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Hide the "View" button when previewing a theme #50986
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ import { | |
useHasEditorCanvasContainer, | ||
} from '../editor-canvas-container'; | ||
import { unlock } from '../../private-apis'; | ||
import { isPreviewingTheme } from '../../utils/is-previewing-theme'; | ||
|
||
const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis ); | ||
|
||
|
@@ -258,37 +259,47 @@ export default function HeaderEditMode() { | |
|
||
<div className="edit-site-header-edit-mode__end"> | ||
<div className="edit-site-header-edit-mode__actions"> | ||
{ ! isFocusMode && hasDefaultEditorCanvasView && ( | ||
<div | ||
className={ classnames( | ||
'edit-site-header-edit-mode__preview-options', | ||
{ 'is-zoomed-out': isZoomedOutView } | ||
) } | ||
> | ||
<PreviewOptions | ||
deviceType={ deviceType } | ||
setDeviceType={ setPreviewDeviceType } | ||
/* translators: button label text should, if possible, be under 16 characters. */ | ||
viewLabel={ __( 'View' ) } | ||
{ ! isFocusMode && | ||
/** | ||
* This isPreviewingTheme() condition can be removed | ||
* once the issues below are fixed | ||
* and previewing the front of the site works well. | ||
* | ||
* https://github.com/WordPress/gutenberg/issues/50713 | ||
* https://github.com/WordPress/gutenberg/issues/50712 | ||
*/ | ||
! isPreviewingTheme() && | ||
hasDefaultEditorCanvasView && ( | ||
<div | ||
className={ classnames( | ||
'edit-site-header-edit-mode__preview-options', | ||
{ 'is-zoomed-out': isZoomedOutView } | ||
) } | ||
> | ||
<MenuGroup> | ||
<MenuItem | ||
href={ homeUrl } | ||
target="_blank" | ||
icon={ external } | ||
> | ||
{ __( 'View site' ) } | ||
<VisuallyHidden as="span"> | ||
{ | ||
/* translators: accessibility text */ | ||
__( '(opens in a new tab)' ) | ||
} | ||
</VisuallyHidden> | ||
</MenuItem> | ||
</MenuGroup> | ||
</PreviewOptions> | ||
</div> | ||
) } | ||
<PreviewOptions | ||
deviceType={ deviceType } | ||
setDeviceType={ setPreviewDeviceType } | ||
/* translators: button label text should, if possible, be under 16 characters. */ | ||
viewLabel={ __( 'View' ) } | ||
> | ||
<MenuGroup> | ||
<MenuItem | ||
href={ homeUrl } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think adding the |
||
target="_blank" | ||
icon={ external } | ||
> | ||
{ __( 'View site' ) } | ||
<VisuallyHidden as="span"> | ||
{ | ||
/* translators: accessibility text */ | ||
__( '(opens in a new tab)' ) | ||
} | ||
</VisuallyHidden> | ||
</MenuItem> | ||
</MenuGroup> | ||
</PreviewOptions> | ||
</div> | ||
) } | ||
<SaveButton /> | ||
<PinnedItems.Slot scope="core/edit-site" /> | ||
<MoreMenu showIconLabels={ showIconLabels } /> | ||
|
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.
These preview options work on within the editor, so I think we should leave them as they are useful here.