-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
[Select][base] Keep focus on the trigger element when listbox is open #37244
Conversation
Netlify deploy previewhttps://deploy-preview-37244--material-ui.netlify.app/ @material-ui/unstyled: parsed: -0.57% 😍, gzip: -0.44% 😍 Bundle size report |
@michaldudak It is much better! https://codesandbox.io/s/base-cra-ts-forked-1kqn3t?file=/src/App.tsx |
@@ -312,24 +312,12 @@ describe('Joy <Select />', () => { | |||
expect(getByRole('combobox')).not.to.have.attribute('aria-disabled'); | |||
}); | |||
|
|||
it('indicates that activating the button displays a listbox', () => { |
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.
According to the ARIA spec, aria-haspopup="listbox"
is applied implicitly when role="combobox"
, so there's no need to add it manually.
it('renders an element with listbox behavior', () => { | ||
const { getByRole } = render(<Select defaultListboxOpen value="" />); | ||
|
||
expect(getByRole('listbox')).toBeVisible(); | ||
}); | ||
|
||
specify('the listbox is automatically focused on open', () => { |
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.
It's not focused on open anymore to prevent stealing focus from other elements on the page.
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.
👍 Great improvement!
This changes the focus behavior of the Select. Previously, when Select was expanded, the listbox received focus. Now, the trigger is always focused. This simplifies focus management and prevents stealing focus when the Select is expanded on mount.
Closes #37023