Fix block selection when transforming via replace#48105
Closed
draganescu wants to merge 1 commit into
Closed
Conversation
|
Size Change: +1 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in f8c206c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4202708974
|
Contributor
Author
|
Hm. So there are two tests failures that seem related. I'll investigate. Edit: I can't repro manually the problem with focusing the preferences modal correctly. Maybe it's flakiness. |
06204d4 to
7505416
Compare
Contributor
Author
|
#48204 makes this obsolete since now the state of selection is not empty anymore. Something will always be selected. |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
In the Navigation Submenu block we have an effect that transforms the submenu into a link when it's last Navigation Link child is removed. This results in a focus loss, with focus moved to the body of the
iframewhere the editor lives.This is surprising because transforming via replace happens two steps:
So in step 2 we have a focus target - the block that replaces the original one.
Why?
Focus loss is one of the worst bugs in terms of using the UI via assistive technology.
How?
When step (1) ends the state of selection is empty! We just removed a block and we don't have any heuristics in place to solve for this. This should be it's own issue - try to remove an image in a group, focus loss.
When step (2) happens the
selectionHelperreducer in theblock-editorstore wrongly returns the empty selection state from (1), when instead we should select the block we just added via replacement in the canvas. This patch does not return that, instead it allows the heurstics in theREPLACE_BLOCKSbranch ofselectionHelperto continue and select the block we just added via replacement.Testing Instructions
and then
8 Check to not get
<body ...but the tag of the submenu.