Skip to content

Commit

Permalink
fix(select): add aria-disabled when disabled (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
reme3d2y committed May 18, 2021
1 parent 6f0ddab commit bd93614
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/select/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,15 @@ describe('Select', () => {
expect(getByRole(ROLE_LISTBOX)).toBeInTheDocument();
});

it('should add disabled class', () => {
render(<Select {...baseProps} label={LABEL_TEXT} options={options} disabled={true} />);
it('should add disabled class and aria-disabled', () => {
const { getByRole } = render(
<Select {...baseProps} label={LABEL_TEXT} options={options} disabled={true} />,
);

expect(document.querySelector('.disabled') as HTMLElement).toBeInTheDocument();

const combobox = getByRole(ROLE_COMBOBOX);
expect(combobox).toHaveAttribute('aria-disabled');
});

it('should add `focused` class', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/select/src/components/base-select/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ export const BaseSelect = forwardRef(
<div
{...getComboboxProps({
ref: rootRef,
...(disabled && { 'aria-disabled': true }),
className: cn(styles.component, { [styles.block]: block }, className),
})}
onKeyDown={disabled ? undefined : handleFieldKeyDown}
Expand Down

0 comments on commit bd93614

Please sign in to comment.