Skip to content

Commit

Permalink
Fix inserter position
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Oct 23, 2024
1 parent b33cdf3 commit 16052f9
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,29 @@ import { unlock } from '../../lock-unlock';
function ZoomOutModeInserters() {
const [ isReady, setIsReady ] = useState( false );
const {
hasSelection,
selectedSectionClientId,
blockOrder,
setInserterIsOpened,
sectionRootClientId,
selectedBlockClientId,
} = useSelect( ( select ) => {
const {
getSettings,
getBlockOrder,
getSelectionStart,
getSelectedBlockClientId,
getSectionRootClientId,
isSectionBlock,
getParentSectionBlock,
} = unlock( select( blockEditorStore ) );

const root = getSectionRootClientId();
const selectionBlockClientId = getSelectedBlockClientId();
const _selectedSectionClientId =
! selectionBlockClientId || isSectionBlock( selectionBlockClientId )
? selectionBlockClientId
: getParentSectionBlock( selectionBlockClientId );

return {
hasSelection: !! getSelectionStart().clientId,
selectedSectionClientId: _selectedSectionClientId,
blockOrder: getBlockOrder( root ),
sectionRootClientId: root,
setInserterIsOpened:
Expand All @@ -54,13 +59,13 @@ function ZoomOutModeInserters() {
};
}, [] );

if ( ! isReady || ! hasSelection ) {
if ( ! isReady || ! selectedSectionClientId ) {
return null;
}

const previousClientId = selectedBlockClientId;
const previousClientId = selectedSectionClientId;
const index = blockOrder.findIndex(
( clientId ) => selectedBlockClientId === clientId
( clientId ) => selectedSectionClientId === clientId
);
const nextClientId = blockOrder[ index + 1 ];

Expand Down

0 comments on commit 16052f9

Please sign in to comment.