Skip to content

Commit

Permalink
Ensure global inserter always targets root nav block
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Sep 9, 2021
1 parent 966781e commit 4a35407
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ function InserterSidebar() {

const { clientId: navBlockClientId } = useNavigationEditorRootBlock();

const { hasInserterItems } = useSelect( ( select ) => {
return {
hasInserterItems: select( blockEditorStore ).hasInserterItems(
navBlockClientId
),
};
}, [] );
const { hasInserterItems, selectedBlockClientId } = useSelect(
( select ) => {
return {
hasInserterItems: select( blockEditorStore ).hasInserterItems(
navBlockClientId
),
selectedBlockClientId: select(
blockEditorStore
).getSelectedBlock()?.clientId,
};
},
[]
);

const { setIsInserterOpened } = useDispatch( editNavigationStore );

Expand All @@ -51,6 +57,11 @@ function InserterSidebar() {
<Library
shouldFocusBlock={ isMobileViewport }
rootClientId={ navBlockClientId }
clientId={
navBlockClientId === selectedBlockClientId
? navBlockClientId
: undefined
}
showInserterHelpPanel={ SHOW_PREVIEWS }
/>
</div>
Expand Down

0 comments on commit 4a35407

Please sign in to comment.