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: remove toggle button from tab order #883

Merged
merged 3 commits into from
Aug 27, 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
9 changes: 9 additions & 0 deletions src/components/Inputs/Input.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ export interface InputIconButtonProps {
* The input icon button onClick event handler.
*/
onClick?: React.MouseEventHandler<HTMLButtonElement>;
/**
* The input icon button role.
*/
role?: string;
/**
* The tabIndex for the icon button. Default is unset (0 since its a button).
* Leverage this to programatically disable the focus for the button as needed.
*/
tabIndex?: number;
}

export interface ReadOnlyProps {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Inputs/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,10 @@ export const TextInput: FC<TextInputProps> = React.forwardRef(
? iconButtonProps.onClick
: null
}
role={iconButtonProps.role}
shape={inputShapeToButtonShapeMap.get(shape)}
size={inputSizeToButtonSizeMap.get(mergedSize)}
tabIndex={iconButtonProps.tabIndex}
transparent
variant={ButtonVariant.SystemUI}
/>
Expand Down Expand Up @@ -548,8 +550,10 @@ export const TextInput: FC<TextInputProps> = React.forwardRef(
path: iconButtonProps.iconProps.path,
}}
id={iconButtonProps.id}
role={iconButtonProps.role}
shape={inputShapeToButtonShapeMap.get(shape)}
size={inputSizeToButtonSizeMap.get(mergedSize)}
tabIndex={iconButtonProps.tabIndex}
variant={ButtonVariant.SystemUI}
/>
)}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,10 @@ export const Select: FC<SelectProps> = React.forwardRef(
? toggleButtonAriaLabel
: 'Toggle dropdown',
htmlType: 'button',
// The button does not need to be the tab order as
// the input itself provides the focus and action.
tabIndex: -1,
role: 'presentation',
iconProps: {
path: dropdownVisible
? IconName.mdiChevronUp
Expand Down
26 changes: 26 additions & 0 deletions src/components/Select/__snapshots__/Select.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ exports[`Select Renders empty options in multiple mode without crashing 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -121,6 +123,8 @@ exports[`Select Renders empty options in single mode without crashing 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -196,6 +200,8 @@ exports[`Select Renders null options in multiple mode without crashing 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -271,6 +277,8 @@ exports[`Select Renders null options in single mode without crashing 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -346,6 +354,8 @@ exports[`Select Renders with default value 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -491,6 +501,8 @@ exports[`Select Renders with default values when multiple 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -566,6 +578,8 @@ exports[`Select Renders without crashing 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -640,6 +654,8 @@ exports[`Select Select is large 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-large icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -713,6 +729,8 @@ exports[`Select Select is medium 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -786,6 +804,8 @@ exports[`Select Select is pill shaped 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium round-shape icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -859,6 +879,8 @@ exports[`Select Select is rectangle shaped 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -932,6 +954,8 @@ exports[`Select Select is small 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-small icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down Expand Up @@ -1005,6 +1029,8 @@ exports[`Select Select is underline shaped 1`] = `
aria-disabled="false"
aria-label="Toggle dropdown"
class="icon-button right-icon button button-system-ui transparent button-medium icon-left"
role="presentation"
tabindex="-1"
type="button"
>
<span
Expand Down
Loading