Skip to content

Commit

Permalink
Zoom Out: fix crash due to absence of selected block (#63642)
Browse files Browse the repository at this point in the history
Co-authored-by: stokesman <[email protected]>
Co-authored-by: jeryj <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: scruffian <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
6 people authored Jul 19, 2024
1 parent 6a2a1db commit 154f1aa
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ export function useShowBlockTools() {
const clientId =
getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();

const block = getBlock( clientId ) || { name: '', attributes: {} };
const block = getBlock( clientId );
const editorMode = __unstableGetEditorMode();
const hasSelectedBlock = clientId && block?.name;
const isEmptyDefaultBlock = isUnmodifiedDefaultBlock( block );
const hasSelectedBlock = !! clientId && !! block;
const isEmptyDefaultBlock =
hasSelectedBlock && isUnmodifiedDefaultBlock( block );
const _showEmptyBlockSideInserter =
clientId &&
! isTyping() &&
Expand All @@ -43,8 +44,9 @@ export function useShowBlockTools() {
! hasMultiSelection() &&
editorMode === 'navigation';

const isZoomOut = editorMode === 'zoom-out';
const _showBlockToolbarPopover =
editorMode !== 'zoom-out' &&
! isZoomOut &&
! getSettings().hasFixedToolbar &&
! _showEmptyBlockSideInserter &&
hasSelectedBlock &&
Expand All @@ -57,7 +59,8 @@ export function useShowBlockTools() {
! _showEmptyBlockSideInserter && maybeShowBreadcrumb,
showBlockToolbarPopover: _showBlockToolbarPopover,
showZoomOutToolbar:
editorMode === 'zoom-out' &&
hasSelectedBlock &&
isZoomOut &&
! _showEmptyBlockSideInserter &&
! maybeShowBreadcrumb &&
! _showBlockToolbarPopover,
Expand Down

0 comments on commit 154f1aa

Please sign in to comment.