Skip to content

Commit

Permalink
Reset active inserter
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed May 8, 2024
1 parent beba18c commit 7cc2bda
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function Inserter( {
previousClientId,
nextClientId,
sectionRootClientId,
__unstableContentRef,
index,
setActiveInserter,
} ) {
Expand All @@ -42,7 +41,6 @@ function Inserter( {
<BlockPopoverInbetween
previousClientId={ previousClientId }
nextClientId={ nextClientId }
__unstableContentRef={ __unstableContentRef }
className="block-editor-button-pattern-inserter"
>
<Button
Expand All @@ -68,7 +66,7 @@ function Inserter( {
function ZoomOutModeInserters( { __unstableContentRef } ) {
const [ isReady, setIsReady ] = useState( false );
const [ activeInserter, setActiveInserter ] = useState( null );
const { blockOrder, sectionRootClientId, blockInsertionPoint } = useSelect(
const { blockOrder, sectionRootClientId, isInserterOpened } = useSelect(
( select ) => {
const { sectionRootClientId: root } = unlock(
select( blockEditorStore ).getSettings()
Expand All @@ -77,18 +75,18 @@ function ZoomOutModeInserters( { __unstableContentRef } ) {
blockOrder: select( blockEditorStore ).getBlockOrder( root ),
// To do: move ZoomOutModeInserters to core/editor.
// eslint-disable-next-line @wordpress/data-no-store-string-literals
blockInsertionPoint: select( 'core/editor' ).isInserterOpened(),
isInserterOpened: select( 'core/editor' ).isInserterOpened(),
sectionRootClientId: root,
};
},
[]
);

useEffect( () => {
if ( ! blockInsertionPoint ) {
if ( ! isInserterOpened ) {
setActiveInserter( null );
}
}, [ blockInsertionPoint ] );
}, [ isInserterOpened ] );

// Defer the initial rendering to avoid the jumps due to the animation.
useEffect( () => {
Expand Down

0 comments on commit 7cc2bda

Please sign in to comment.