-
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
Writing Flow: restore early return for no block selection in tab nav hook #69079
Writing Flow: restore early return for no block selection in tab nav hook #69079
Conversation
… fix the focus ts error
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Failing test seems irrelevant to changes as both failed with status exit |
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.
This looks good to me. This rest of this comment is for easier reference and explanation. The early return was removed here. This restores it though moves it to an even earlier location. It’s new location should be inconsequential to the result of the hook. The only concern that I could imagine would be a potential micro-optimization. If it were placed after the other condition for early return that tests for the Tab key. That one might be a lighter test and if so should run first. I doubt it would make any significant difference but I wanted to be thorough in noting what’s different.
Do we want to try this? If we follow the original process, it should look like this: if ( event.keyCode !== TAB ) {
return;
}
const isShift = event.shiftKey;
const direction = isShift ? 'findPrevious' : 'findNext';
if ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {
return;
}
const nextTabbable = focus.tabbable[ direction ]( event.target ); |
Your example is true to the prior execution. My nitpick with that would be that the early return we are restoring should go before the if ( event.keyCode !== TAB ) {
return;
}
if ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {
return;
}
const isShift = event.shiftKey;
const direction = isShift ? 'findPrevious' : 'findNext';
const nextTabbable = focus.tabbable[ direction ]( event.target ); |
if ( event.keyCode !== TAB ) {
return;
}
if ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {
return;
}
const isShift = event.shiftKey;
const direction = isShift ? 'findPrevious' : 'findNext';
const nextTabbable = focus.tabbable[ direction ]( event.target ); This seems to work perfectly, should we go ahead with this? |
@Mayank-Tripathi32 Let's give it a try. |
What?
Closes #69037
Fixes tab navigation error in Site Editor preview frame
Why?
Tab navigation from preview frame causes console errors after #65204 removed an early return condition. Issue doesn't exist in WP 6.7.1 without Gutenberg.
How?
Restores early return in useTabNav hook:
This prevents unnecessary processing when no selection exists, fixing the error while maintaining functionality.
Testing Instructions
Testing Instructions for Keyboard
ScreenCast
Test.Focus.mov