Skip to content

Commit

Permalink
Fix don't show inserter in Zoom Out dropzone when the text is visible (
Browse files Browse the repository at this point in the history
…WordPress#68031)

* Hide inserter

* Comment case

Co-authored-by: Sarah Norris <1645628+mikachan@users.noreply.github.com>

---------

Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>
Co-authored-by: mikachan <mikachan@git.wordpress.org>
  • Loading branch information
4 people authored Dec 17, 2024
1 parent ca298ed commit 7dd3127
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 7dd3127

Please sign in to comment.