-
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
Inserter: Should receive focus on open #67754
Conversation
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. |
// A test for https://github.com/WordPress/gutenberg/issues/43090. | ||
await test.step( 'should close the inserter when clicking on the toggle button', async () => { | ||
const beforeBlocks = await editor.getBlocks(); | ||
|
||
await InserterUtils.openBlockLibrary(); | ||
await InserterUtils.expectActiveTab( 'Blocks' ); | ||
await InserterUtils.blockLibrary | ||
.getByRole( 'option', { name: 'Buttons' } ) | ||
.click(); | ||
|
||
await expect | ||
.poll( editor.getBlocks ) | ||
.toMatchObject( [ ...beforeBlocks, { name: 'core/buttons' } ] ); | ||
|
||
await InserterUtils.closeBlockLibrary(); | ||
} ); |
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.
Moving this into a step for better organization and saving a bit of time on e2e test runs.
Size Change: -5 B (0%) Total Size: 1.83 MB
ℹ️ View Unchanged
|
Flaky tests detected in e33629d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12240299426
|
@@ -82,6 +82,8 @@ function InserterMenu( | |||
if ( isZoomOutMode ) { | |||
return 'patterns'; | |||
} | |||
|
|||
return 'blocks'; |
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.
Not sure why we missed this. The getInitialTab
should always return value.
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.
Yeah, I'm surprised we missed it too. I guess we know we're human :)
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, @jeryj! This works as expected ✅
I've unlinked the issue since the error remains.
Screenshot
CleanShot.2024-12-09.at.21.31.55.mp4
This impacted the "inserter open" metric. That said, it might just because previously we were just rendering nothing right? |
@youknowriad That's very odd. Since this impacted the inserter open metric, I'd say there's a different underlying issue this is exposing. It doesn't change what is rendered, just tells the inserter what tab to move focus to when it opens. |
Yeah, a 20%+ increase is odd, but then the previous version of |
Previously, the Maybe with |
Yes, this is my guess, in which case, there's nothing to revert, but maybe we can try to make the metric independent of the "sync/asynchronous" behavior and count the time until first block is rendered or something. |
See #67755
What?
We were relying on the tabs component to set an initial tab for us, and then focusing it afterwards. It seems like something has changed within the tabs component's behavior where the selected tab is getting set too late, and our auto-focus check has already completed. Passing which tab we want selected fixes it.
Why?
Consistent behavior and readability. Since we will always have an initial tab selected, it's easier to understand the code if there's always a default tab set instead of having the tabs component guess which one for us.
How?
Sets an initial tab to be focused if none is manually passed.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast