Skip to content

Commit

Permalink
Hide inserter
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Dec 16, 2024
1 parent 2ee383c commit dbad7a0
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ function ZoomOutModeInserters() {
setInserterIsOpened,
sectionRootClientId,
selectedBlockClientId,
blockInsertionPoint,
insertionPointVisible,
} = useSelect( ( select ) => {
const {
getSettings,
getBlockOrder,
getSelectionStart,
getSelectedBlockClientId,
getSectionRootClientId,
getBlockInsertionPoint,
isBlockInsertionPointVisible,
} = unlock( select( blockEditorStore ) );

const root = getSectionRootClientId();
Expand All @@ -38,6 +42,8 @@ function ZoomOutModeInserters() {
setInserterIsOpened:
getSettings().__experimentalSetIsInserterOpened,
selectedBlockClientId: getSelectedBlockClientId(),
blockInsertionPoint: getBlockInsertionPoint(),
insertionPointVisible: isBlockInsertionPointVisible(),
};
}, [] );

Expand All @@ -62,7 +68,19 @@ function ZoomOutModeInserters() {
const index = blockOrder.findIndex(
( clientId ) => selectedBlockClientId === clientId
);
const nextClientId = blockOrder[ index + 1 ];

const insertionIndex = index + 1;

const nextClientId = blockOrder[ insertionIndex ];

// if the block insertion point is visible, and the insertion
// indicies match then we don't need to render the inserter.
if (
insertionPointVisible &&
blockInsertionPoint?.index === insertionIndex
) {
return null;
}

return (
<BlockPopoverInbetween
Expand All @@ -73,11 +91,11 @@ function ZoomOutModeInserters() {
onClick={ () => {
setInserterIsOpened( {
rootClientId: sectionRootClientId,
insertionIndex: index + 1,
insertionIndex,
tab: 'patterns',
category: 'all',
} );
showInsertionPoint( sectionRootClientId, index + 1, {
showInsertionPoint( sectionRootClientId, insertionIndex, {
operation: 'insert',
} );
} }
Expand Down

0 comments on commit dbad7a0

Please sign in to comment.