WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.19k forks source link

Use the `areInnerBlocksControlled` selector to detect Controlled blocks in Nav block #46265

Open getdave opened 1 year ago

getdave commented 1 year ago

In packages/block-library/src/navigation/edit/use-inner-blocks.js we are relying on a quirk of getBlock/getBlocks to determine whether blocks are controlled/uncontrolled.

We should move this to use the official API areInnerBlocksControlled.


    @talldan I wonder if we could consider [using the `areInnerBlocksControlled` selector now](https://github.com/WordPress/gutenberg/blob/149c3a37d70d44ae8a99c7ca0e172935f9ab77a0/packages/block-library/src/navigation/edit/use-inner-blocks.js#L15-L18) to detect whether blocks are controlled?

Originally posted by @getdave in https://github.com/WordPress/gutenberg/issues/46223#issuecomment-1333637789

talldan commented 1 year ago

Sharing my comments on that linked issue about some potential challenges - https://github.com/WordPress/gutenberg/pull/46223#issuecomment-1336757267.

The getBlock/getBlocks thing is very hacky, so it'd indeed be great to think up an alternative.