-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix block selection when transforming via replace #48105
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
|
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
#48204 makes this obsolete since now the state of selection is not empty anymore. Something will always be selected. |
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
iframe
where 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
selectionHelper
reducer in theblock-editor
store 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_BLOCKS
branch ofselectionHelper
to 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.