Skip to content
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(select): Update aria-haspopup to 'menu' #2760

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cypress/integration/Select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,22 @@ describe('Select', () => {
h.stories.load('Components/Inputs/Select', 'Basic');
});

it('should have a combobox role', () => {
cy.findByRole('combobox').should('have.attr', 'role', 'combobox');
});

it('should have an `aria-popup="menu"`', () => {
cy.findByRole('combobox').should('have.attr', 'aria-haspopup', 'menu');
});

it('should have an `aria-expanded="false"`', () => {
cy.findByRole('combobox').should('have.attr', 'aria-expanded', 'false');
});

it('should have an `aria-autocomplete="list"`', () => {
cy.findByRole('combobox').should('have.attr', 'aria-autocomplete', 'list');
});

context('when the menu is opened', () => {
beforeEach(() => {
cy.findByRole('combobox').focus().realType('{downarrow}');
Expand Down
10 changes: 5 additions & 5 deletions modules/react/select/lib/hooks/useSelectInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ function noop() {
* `useSelectInput` extends {@link useComboboxInput useComboboxInput} and {@link useComboboxKeyboardTypeAhead useComboboxKeyboardTypeAhead} and adds type ahead functionality and Select-specific [keyboard support](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/).
*/
export const useSelectInput = composeHooks(
useComboboxInput,
useComboboxKeyboardTypeAhead,
useComboboxResetCursorToSelected,
useComboboxMoveCursorToSelected,
createElemPropsHook(useSelectModel)(
(model, ref, elemProps: {keySofar?: string; placeholder?: string; value?: string} = {}) => {
const {elementRef} = useLocalRef<HTMLInputElement>(ref as any);
Expand Down Expand Up @@ -158,9 +162,5 @@ export const useSelectInput = composeHooks(
'aria-haspopup': 'menu',
} as const;
}
),
useComboboxKeyboardTypeAhead,
useComboboxResetCursorToSelected,
useComboboxMoveCursorToSelected,
useComboboxInput
)
);
Loading