Using dispatch( 'core/editor' ).selectBlock for a nested block focuses on its inner child instead #9212
Labels
[Feature] Nested / Inner Blocks
Anything related to the experience of nested/inner blocks inside a larger container, like Group or P
[Type] Bug
An existing feature does not function as intended
Milestone
Describe the bug
We are creating UI for being able to select nested blocks from a list of links. Added a new component which displays a root-level block and its inner first level children in a list of links. Clicking on a link triggers
dispatch( 'core/editor' ).selectBlock( clientId )
with the relevant block'sclientId
. For some reason instead of the block with the specifiedclientId
being selected its first inner child gets selected.For example if the blocks are nested A > B > C then calling
dispatch( 'core/editor' ).selectBlock( clientId )
with theclientId
ofB
focuses on the blockC
is instead. DebuggingclientId
on these lines shows that for some reason this runs twice -- first time with the correctclientId
and the second time with theclientId
of the first inner block (C
).Note that using
selectBlock
with the root level element (A
in the example) selects the correct block.PR and the line in the PR using
selectBlock
: https://github.com/Automattic/amp-wp/pull/1347/files#diff-34cc40d7d5ae6b1abcceb3757490f8ecR45Expected behavior
The block which
clientId
is used withdispatch( 'core/editor' ).selectBlock
should be selected.Additional context
The text was updated successfully, but these errors were encountered: