Writing Flow: Avoid auto-focus on nested blocks#5092
Conversation
| // Avoid selecting the target if it's: | ||
| // - The default block appender (or generally uneditable) | ||
| // - Within a nested block | ||
| if ( target.readOnly || target.closest( '[data-block]' ) !== blockContainer ) { |
There was a problem hiding this comment.
This breaks some behaviors:
- splitting inside container blocks like "columns".
- selecting an image and hitting Enter inside container blocks
There was a problem hiding this comment.
Hmm, I can confirm this, though I wouldn't have expected it, since these behaviors should be finding inputs within the selected block, at which point it should be finding the selected nested's inputs correctly. Will investigate...
|
There's a few related issues which contribute to the breakage in nested writing flow:
|
|
Or we could add a |
On second thought, even though this is true, the later insertion of the default block should change the selection and trigger another |
|
In fact, I think these are the same issue: That the second component updates, but the new default block isn't yet present in the DOM, same as noted for splitting. |
|
Closed in favor of #5102 |
Related: #4872 (comment)
This pull request seeks to resolve an issue where it is difficult to use the ellipsis More Options menu for the Column block due to focus transitioning into the block. The changes here revise the logic for focusing the newly-selected block to ensure that the selected block is not within a nested block, since if it is, the selected block will change and the menu will become dismissed.
Testing instructions:
Verify that you can open the More Options ellipsis menu, both for the Columns block and a non-nesting block. In the latter case, ensure that focus is still transitioned within the block.
Verify there are no regressions in the behavior where this auto-focus behavior is necessary: