Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using dispatch( 'core/editor' ).selectBlock for a nested block focuses on its inner child instead #9212

Closed
miina opened this issue Aug 21, 2018 · 0 comments · Fixed by #10545
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

Comments

@miina
Copy link
Contributor

miina commented Aug 21, 2018

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's clientId. For some reason instead of the block with the specified clientId 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 the clientId of B focuses on the block C is instead. Debugging clientId on these lines shows that for some reason this runs twice -- first time with the correct clientId and the second time with the clientId 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-34cc40d7d5ae6b1abcceb3757490f8ecR45

Expected behavior
The block which clientId is used with dispatch( 'core/editor' ).selectBlock should be selected.

Additional context

  • Gutenberg version: 3.6.2
@westonruter westonruter added the [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P label Aug 21, 2018
@designsimply designsimply added the Needs Technical Feedback Needs testing from a developer perspective. label Aug 21, 2018
@mtias mtias added this to the API Freeze milestone Oct 11, 2018
@youknowriad youknowriad added [Type] Bug An existing feature does not function as intended and removed Needs Technical Feedback Needs testing from a developer perspective. labels Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants