Skip to content

Commit

Permalink
Hide active inserter
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 8, 2024
1 parent ba6a804 commit e1f2b05
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function Inserter( {
blockOrder,
__unstableContentRef,
index,
setActiveInserter,
} ) {
const { setInserterIsOpened, insertionIndex } = useSelect(
( select ) => {
Expand Down Expand Up @@ -57,6 +58,7 @@ function Inserter( {
tab: 'patterns',
category: 'all',
} );
setActiveInserter( index );
} }
label={ label }
/>
Expand All @@ -66,6 +68,7 @@ function Inserter( {

function ZoomOutModeInserters( { __unstableContentRef } ) {
const [ isReady, setIsReady ] = useState( false );
const [ activeInserter, setActiveInserter ] = useState( null );
const { blockOrder, sectionRootClientId } = useSelect( ( select ) => {
const { sectionRootClientId: root } = unlock(
select( blockEditorStore ).getSettings()
Expand All @@ -91,6 +94,9 @@ function ZoomOutModeInserters( { __unstableContentRef } ) {
}

return blockOrder.map( ( clientId, index ) => {
if ( activeInserter === index ) {
return null;
}
if ( index === blockOrder.length - 1 ) {
return null;
}
Expand All @@ -102,6 +108,7 @@ function ZoomOutModeInserters( { __unstableContentRef } ) {
index={ index }
blockOrder={ blockOrder }
__unstableContentRef={ __unstableContentRef }
setActiveInserter={ setActiveInserter }
/>
);
} );
Expand Down

0 comments on commit e1f2b05

Please sign in to comment.