Skip to content

Commit

Permalink
Don't hide the toolbar when in-between inserter is visible
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 17, 2021
1 parent 80445de commit 9bcf4d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 18 additions & 3 deletions packages/block-editor/src/components/block-tools/block-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function selector( select ) {
isCaretWithinFormattedText,
getSettings,
getLastMultiSelectedBlockClientId,
isBlockInsertionPointVisible,
} = select( blockEditorStore );
return {
isNavigationMode: isNavigationMode(),
Expand All @@ -44,7 +43,6 @@ function selector( select ) {
hasMultiSelection: hasMultiSelection(),
hasFixedToolbar: getSettings().hasFixedToolbar,
lastClientId: getLastMultiSelectedBlockClientId(),
isInsertionPointVisible: isBlockInsertionPointVisible(),
};
}

Expand All @@ -65,8 +63,25 @@ function BlockPopover( {
hasMultiSelection,
hasFixedToolbar,
lastClientId,
isInsertionPointVisible,
} = useSelect( selector, [] );
const isInsertionPointVisible = useSelect(
( select ) => {
const {
isBlockInsertionPointVisible,
getBlockInsertionPoint,
getBlockOrder,
} = select( blockEditorStore );

if ( ! isBlockInsertionPointVisible() ) {
return false;
}

const insertionPoint = getBlockInsertionPoint();
const order = getBlockOrder( insertionPoint.rootClientId );
return order[ insertionPoint.index ] === clientId;
},
[ clientId ]
);
const isLargeViewport = useViewportMatch( 'medium' );
const [ isToolbarForced, setIsToolbarForced ] = useState( false );
const [ isInserterShown, setIsInserterShown ] = useState( false );
Expand Down
6 changes: 5 additions & 1 deletion packages/block-editor/src/components/block-tools/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@
}
}

&.is-insertion-point-visible,
// Hide the block toolbar if the insertion point is shown.
&.is-insertion-point-visible {
visibility: hidden;
}

.is-dragging-components-draggable & {
opacity: 0;
// Use a minimal duration to delay hiding the element, see hide-during-dragging animation for more details.
Expand Down

0 comments on commit 9bcf4d0

Please sign in to comment.