Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use isEnabled prop
  • Loading branch information
t-hamano committed Aug 29, 2023
commit 7f550cc69baf7a6a5f916e58c423cf5d4d6da2a0
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function PreviewOptions( {
const toggleProps = {
className: 'block-editor-post-preview__button-toggle',
disabled: ! isEnabled,
__experimentalIsFocusable: ! isEnabled,
Copy link
Contributor Author

@t-hamano t-hamano Aug 29, 2023

Choose a reason for hiding this comment

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

I have added this prop to make the dropdown focusable even when it is disabled and to show the tooltip. This change will also affect the preview option button in the Post Editor. Do you think this should not be added in this PR?

Copy link
Member

Choose a reason for hiding this comment

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

No, that's fine and a good improvement here.

I just realized that we also need to set disableOpenOnArrowDown based on the enabled status to avoid the opening drop via the arrow-down key. Pushed changes here 758e448.

Screencast

CleanShot.2023-08-29.at.17.13.47.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for finding it, @Mamaduka!

children: viewLabel,
};
const menuProps = {
Expand Down
68 changes: 28 additions & 40 deletions packages/edit-site/src/components/header-edit-mode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ import {
import { useSelect, useDispatch } from '@wordpress/data';
import { PinnedItems } from '@wordpress/interface';
import { _x, __ } from '@wordpress/i18n';
import {
desktop,
listView,
plus,
external,
chevronUpDown,
} from '@wordpress/icons';
import { listView, plus, external, chevronUpDown } from '@wordpress/icons';
import {
__unstableMotion as motion,
Button,
Expand Down Expand Up @@ -325,39 +319,33 @@ export default function HeaderEditMode() {
{ 'is-zoomed-out': isZoomedOutView }
) }
>
{ ! isFocusMode && hasDefaultEditorCanvasView ? (
<PreviewOptions
deviceType={ deviceType }
setDeviceType={ setPreviewDeviceType }
label={ __( 'View' ) }
>
{ ( { onClose } ) => (
<MenuGroup>
<MenuItem
href={ homeUrl }
target="_blank"
icon={ external }
onClick={ onClose }
>
{ __( 'View site' ) }
<VisuallyHidden as="span">
{
/* translators: accessibility text */
__( '(opens in a new tab)' )
}
</VisuallyHidden>
</MenuItem>
</MenuGroup>
) }
</PreviewOptions>
) : (
<Button
label={ __( 'View' ) }
icon={ desktop }
disabled
__experimentalIsFocusable
/>
) }
<PreviewOptions
deviceType={ deviceType }
setDeviceType={ setPreviewDeviceType }
label={ __( 'View' ) }
isEnabled={
! isFocusMode && hasDefaultEditorCanvasView
}
>
{ ( { onClose } ) => (
<MenuGroup>
<MenuItem
href={ homeUrl }
target="_blank"
icon={ external }
onClick={ onClose }
>
{ __( 'View site' ) }
<VisuallyHidden as="span">
{
/* translators: accessibility text */
__( '(opens in a new tab)' )
}
</VisuallyHidden>
</MenuItem>
</MenuGroup>
) }
</PreviewOptions>
</div>
<SaveButton />
{ ! isDistractionFree && (
Expand Down