diff --git a/packages/block-editor/src/components/block-navigation/dropdown.js b/packages/block-editor/src/components/block-navigation/dropdown.js index ba0e824c3667c..2496d8cdfdbd9 100644 --- a/packages/block-editor/src/components/block-navigation/dropdown.js +++ b/packages/block-editor/src/components/block-navigation/dropdown.js @@ -23,7 +23,12 @@ const MenuIcon = ( ); -function BlockNavigationDropdownToggle( { isEnabled, onToggle, isOpen } ) { +function BlockNavigationDropdownToggle( { + isEnabled, + onToggle, + isOpen, + showTooltip, +} ) { useShortcut( 'core/edit-post/toggle-block-navigation', useCallback( onToggle, [ onToggle ] ), @@ -49,12 +54,14 @@ function BlockNavigationDropdownToggle( { isEnabled, onToggle, isOpen } ) { className="block-editor-block-navigation" shortcut={ shortcut } aria-disabled={ ! isEnabled } + showTooltip={ showTooltip } /> ); } function BlockNavigationDropdown( { isDisabled, + showTooltip, __experimentalWithBlockNavigationSlots, } ) { const hasBlocks = useSelect( @@ -71,6 +78,7 @@ function BlockNavigationDropdown( { ) } renderContent={ ( { onClose } ) => ( diff --git a/packages/block-editor/src/components/tool-selector/index.js b/packages/block-editor/src/components/tool-selector/index.js index e09c516eca132..eb74e4a3251e2 100644 --- a/packages/block-editor/src/components/tool-selector/index.js +++ b/packages/block-editor/src/components/tool-selector/index.js @@ -34,7 +34,7 @@ const selectIcon = ( ); -function ToolSelector() { +function ToolSelector( { showTooltip } ) { const isNavigationTool = useSelect( ( select ) => select( 'core/block-editor' ).isNavigationMode(), [] @@ -57,6 +57,7 @@ function ToolSelector() { aria-expanded={ isOpen } onClick={ onToggle } label={ __( 'Tools' ) } + showTooltip={ showTooltip } /> ) } position="bottom right" diff --git a/packages/components/src/button/index.js b/packages/components/src/button/index.js index 7e5acfb6f2ccf..08af4bb17adc0 100644 --- a/packages/components/src/button/index.js +++ b/packages/components/src/button/index.js @@ -36,6 +36,7 @@ export function Button( props, ref ) { disabled, icon, iconSize, + showIconLabel, showTooltip, tooltipPosition, shortcut, @@ -94,8 +95,7 @@ export function Button( props, ref ) { ! trulyDisabled && // an explicit tooltip is passed or... ( ( showTooltip && label ) || - // there's a shortcut or... - shortcut || + ( shortcut && showTooltip !== false ) || // there's a label and... ( !! label && // the children are empty and... @@ -113,6 +113,7 @@ export function Button( props, ref ) { ref={ ref } > { icon && } + { showIconLabel &&
{ label }
} { children } ); diff --git a/packages/components/src/button/style.scss b/packages/components/src/button/style.scss index 559d207972bb9..8b4cb2e9d3a6f 100644 --- a/packages/components/src/button/style.scss +++ b/packages/components/src/button/style.scss @@ -13,7 +13,6 @@ align-items: center; box-sizing: border-box; padding: 6px 12px; - overflow: hidden; border-radius: $radius-block-ui; color: $dark-gray-primary; @@ -280,6 +279,11 @@ outline: none; } + .label { + flex-basis: 100%; + margin-left: 5px; + } + // Fixes a Safari+VoiceOver bug, where the screen reader text is announced not respecting the source order. // See https://core.trac.wordpress.org/ticket/42006 and https://github.com/h5bp/html5-boilerplate/issues/1985 .components-visually-hidden { diff --git a/packages/components/src/dropdown-menu/index.js b/packages/components/src/dropdown-menu/index.js index 288ea6f72d9d4..7a8eeef193630 100644 --- a/packages/components/src/dropdown-menu/index.js +++ b/packages/components/src/dropdown-menu/index.js @@ -2,7 +2,7 @@ * External dependencies */ import classnames from 'classnames'; -import { flatMap, isEmpty, isFunction } from 'lodash'; +import { flatMap, isEmpty, isFunction, isUndefined } from 'lodash'; /** * WordPress dependencies @@ -124,7 +124,11 @@ function DropdownMenu( { aria-haspopup="true" aria-expanded={ isOpen } label={ label } - showTooltip + showTooltip={ + isUndefined( mergedToggleProps.showTooltip ) + ? true + : mergedToggleProps.showTooltip + } > { mergedToggleProps.children } diff --git a/packages/edit-post/src/components/header/header-toolbar/index.js b/packages/edit-post/src/components/header/header-toolbar/index.js index 4e386d22cc4f7..09d32ed2b69a9 100644 --- a/packages/edit-post/src/components/header/header-toolbar/index.js +++ b/packages/edit-post/src/components/header/header-toolbar/index.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ @@ -25,6 +30,7 @@ function HeaderToolbar( { onToggleInserter, isInserterOpen } ) { isInserterVisible, isTextModeEnabled, previewDeviceType, + showIconLabels, } = useSelect( ( select ) => ( { hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( @@ -40,14 +46,20 @@ function HeaderToolbar( { onToggleInserter, isInserterOpen } ) { previewDeviceType: select( 'core/edit-post' ).__experimentalGetPreviewDeviceType(), + showIconLabels: select( 'core/edit-post' ).isFeatureActive( + 'showIconLabels' + ), } ), [] ); const isLargeViewport = useViewportMatch( 'medium' ); + const isWideViewport = useViewportMatch( 'wide' ); const displayBlockToolbar = ! isLargeViewport || previewDeviceType !== 'Desktop' || hasFixedToolbar; + const showTooltip = ! showIconLabels; + const toolbarAriaLabel = displayBlockToolbar ? /* translators: accessibility text for the editor toolbar when Top Toolbar is on */ __( 'Document and block tools' ) @@ -56,8 +68,10 @@ function HeaderToolbar( { onToggleInserter, isInserterOpen } ) { return ( { isInserterVisible && (