Skip to content

Commit

Permalink
Top Toolbar: Show document bar when no block is selected even if bloc…
Browse files Browse the repository at this point in the history
…k tools are expanded (#65839)

* Top Toolbar: Show document bar when no block is selected even if block tools are expanded

* Change variable name to hasBlockSelection

----

Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: eatse21 <eatse@git.wordpress.org>
  • Loading branch information
4 people authored Oct 3, 2024
1 parent edcd976 commit 20f35dd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/editor/src/components/header/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import { store as blockEditorStore } from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
import { useMediaQuery, useViewportMatch } from '@wordpress/compose';
import { __unstableMotion as motion } from '@wordpress/components';
Expand Down Expand Up @@ -52,12 +53,13 @@ function Header( {
const isLargeViewport = useViewportMatch( 'medium' );
const isTooNarrowForDocumentBar = useMediaQuery( '(max-width: 403px)' );
const {
postType,
isTextEditor,
isPublishSidebarOpened,
showIconLabels,
hasFixedToolbar,
hasBlockSelection,
isNestedEntity,
postType,
} = useSelect( ( select ) => {
const { get: getPreference } = select( preferencesStore );
const {
Expand All @@ -73,6 +75,8 @@ function Header( {
isPublishSidebarOpened: _isPublishSidebarOpened(),
showIconLabels: getPreference( 'core', 'showIconLabels' ),
hasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),
hasBlockSelection:
!! select( blockEditorStore ).getBlockSelectionStart(),
isNestedEntity:
!! getEditorSettings().onNavigateToPreviousEntityRecord,
};
Expand All @@ -85,7 +89,9 @@ function Header( {
const [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =
useState( true );

const hasCenter = isBlockToolsCollapsed && ! isTooNarrowForDocumentBar;
const hasCenter =
( ! hasBlockSelection || isBlockToolsCollapsed ) &&
! isTooNarrowForDocumentBar;
const hasBackButton = useHasBackButton();
/*
* The edit-post-header classname is only kept for backward compatability
Expand Down

0 comments on commit 20f35dd

Please sign in to comment.