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

Tooltip: Don't render buttons tooltip when show button text labels is enabled #55842

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function PreviewOptions( {
deviceType,
setDeviceType,
label,
showIconLabels,
} ) {
const isMobile = useViewportMatch( 'small', '<' );
if ( isMobile ) return null;
Expand All @@ -35,6 +36,7 @@ export default function PreviewOptions( {
disabled: ! isEnabled,
__experimentalIsFocusable: ! isEnabled,
children: viewLabel,
showTooltip: ! showIconLabels,
};
const menuProps = {
'aria-label': __( 'View options' ),
Expand Down
36 changes: 21 additions & 15 deletions packages/edit-post/src/components/device-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,27 @@ import { store as coreStore } from '@wordpress/core-data';
import { store as editPostStore } from '../../store';

export default function DevicePreview() {
const { hasActiveMetaboxes, isPostSaveable, isViewable, deviceType } =
useSelect( ( select ) => {
const { getEditedPostAttribute } = select( editorStore );
const { getPostType } = select( coreStore );
const postType = getPostType( getEditedPostAttribute( 'type' ) );
const {
hasActiveMetaboxes,
isPostSaveable,
isViewable,
deviceType,
showIconLabels,
} = useSelect( ( select ) => {
const { getEditedPostAttribute } = select( editorStore );
const { getPostType } = select( coreStore );
const postType = getPostType( getEditedPostAttribute( 'type' ) );

return {
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
isPostSaveable: select( editorStore ).isEditedPostSaveable(),
isViewable: postType?.viewable ?? false,
deviceType:
select(
editPostStore
).__experimentalGetPreviewDeviceType(),
};
}, [] );
return {
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
isPostSaveable: select( editorStore ).isEditedPostSaveable(),
isViewable: postType?.viewable ?? false,
deviceType:
select( editPostStore ).__experimentalGetPreviewDeviceType(),
showIconLabels:
select( editPostStore ).isFeatureActive( 'showIconLabels' ),
};
}, [] );
const { __experimentalSetPreviewDeviceType: setPreviewDeviceType } =
useDispatch( editPostStore );

Expand All @@ -41,6 +46,7 @@ export default function DevicePreview() {
deviceType={ deviceType }
setDeviceType={ setPreviewDeviceType }
label={ __( 'Preview' ) }
showIconLabels={ showIconLabels }
>
{ ( { onClose } ) =>
isViewable && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export default function HeaderEditMode( { setListViewToggleElement } ) {
isEnabled={
! isFocusMode && hasDefaultEditorCanvasView
}
showIconLabels={ showIconLabels }
>
{ ( { onClose } ) => (
<MenuGroup>
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/save-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function SaveButton( {
* Displaying the keyboard shortcut conditionally makes the tooltip
* itself show conditionally. This would trigger a full-rerendering
* of the button that we want to avoid. By setting `showTooltip`,
& the tooltip is always rendered even when there's no keyboard shortcut.
* the tooltip is always rendered even when there's no keyboard shortcut.
*/
showTooltip={ showTooltip }
icon={ icon }
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/post-saved-state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default function PostSavedState( {
* Displaying the keyboard shortcut conditionally makes the tooltip
* itself show conditionally. This would trigger a full-rerendering
* of the button that we want to avoid. By setting `showTooltip`,
& the tooltip is always rendered even when there's no keyboard shortcut.
* the tooltip is always rendered even when there's no keyboard shortcut.
*/
showTooltip
variant="tertiary"
Expand Down
Loading