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
…#68031)

* Hide inserter

* Comment case

Co-authored-by: Sarah Norris <[email protected]>

---------

Co-authored-by: getdave <[email protected]>
Co-authored-by: MaggieCabrera <[email protected]>
Co-authored-by: mikachan <[email protected]>
  • 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

1 comment on commit 7dd3127

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 7dd3127.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12373351463
📝 Reported issues:

Please sign in to comment.