-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 focus loss after converting to a synced pattern #55473
Merged
Merged
Conversation
This file contains 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
kevin940726
added
[Type] Bug
An existing feature does not function as intended
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Feature] Patterns
A collection of blocks that can be synced (previously reusable blocks) or unsynced
labels
Oct 19, 2023
kevin940726
force-pushed
the
fix/convert-pattern-focus-loss
branch
from
October 19, 2023 06:30
f9e7ead
to
d38d492
Compare
Size Change: +37 B (0%) Total Size: 1.66 MB
ℹ️ View Unchanged
|
aaronrobertshaw
approved these changes
Nov 17, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing this @kevin940726 👍
The explanation as to the cause of the issue and the solution makes sense to me. It all tests as advertised too.
LGTM 🚢
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Feature] Patterns
A collection of blocks that can be synced (previously reusable blocks) or unsynced
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Type] Bug
An existing feature does not function as intended
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?
Fix focus loss when converting a block to a synced pattern via the block settings toolbar.
Why?
As originally discovered in #55406 (review), this bug seems to have been broken for a long time (3y+?).
How?
The issue is that we're fetching the pattern after we convert it to a pattern. If the response comes late then we show a placeholder state. The placeholder state renders a different
<div>
which will get unmounted/removed after the entity is resolved. However,replaceBlocks
triggers focusing the block immediately after it's inserted, which then attempts to focus the placeholder<div>
. It succeeded, but the placeholder<div>
unmounts thus the focus is lost.The solution is to reuse the same
<div>
component for each state, so that React will attempt to render the same element without destroying and remounting them.Testing Instructions
Added e2e tests.
Testing Instructions for Keyboard
Screenshots or screencast
Kapture.2023-10-19.at.14.27.44.mp4