Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions packages/block-library/src/navigation/edit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,8 @@ function Navigation( {
await createNavigationMenu( '' );
};

const {
hasUncontrolledInnerBlocks,
uncontrolledInnerBlocks,
isInnerBlockSelected,
innerBlocks,
} = useInnerBlocks( clientId );
const { hasUncontrolledInnerBlocks, isInnerBlockSelected, innerBlocks } =
useInnerBlocks( clientId );

const {
replaceInnerBlocks,
Expand Down Expand Up @@ -997,7 +993,7 @@ function Navigation( {
>
<UnsavedInnerBlocks
createNavigationMenu={ createNavigationMenu }
blocks={ uncontrolledInnerBlocks }
blocks={ innerBlocks }
hasSelection={ isSelected || isInnerBlockSelected }
/>
</ResponsiveWrapper>
Expand Down
36 changes: 0 additions & 36 deletions packages/block-library/src/navigation/edit/use-inner-blocks.js

This file was deleted.

35 changes: 35 additions & 0 deletions packages/block-library/src/navigation/edit/use-inner-blocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { useSelect } from '@wordpress/data';
import { store as blockEditorStore } from '@wordpress/block-editor';
import type { Block } from '@wordpress/blocks';

interface InnerBlocks {
innerBlocks: Block[];
hasUncontrolledInnerBlocks: boolean;
isInnerBlockSelected: boolean;
}

export function useInnerBlocks( clientId: string ): InnerBlocks {
return useSelect(
( select ) => {
const {
areInnerBlocksControlled,
getBlocks,
hasSelectedInnerBlock,
} = select( blockEditorStore );

// Inner blocks become controlled once they are synced with a
// `wp_navigation` entity. Until then, any inner blocks belong to
// the Navigation block itself.
const innerBlocks = getBlocks( clientId );

return {
innerBlocks,
hasUncontrolledInnerBlocks:
! areInnerBlocksControlled( clientId ) &&
!! innerBlocks.length,
isInnerBlockSelected: hasSelectedInnerBlock( clientId, true ),
};
},
[ clientId ]
);
}
5 changes: 0 additions & 5 deletions tools/eslint/suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3372,11 +3372,6 @@
"count": 1
}
},
"packages/block-library/src/navigation/edit/use-inner-blocks.js": {
"gutenberg/use-typescript": {
"count": 1
}
},
"packages/block-library/src/navigation/edit/use-layout-custom-properties.js": {
"gutenberg/use-typescript": {
"count": 1
Expand Down
Loading