Skip to content

Commit

Permalink
move the aria label of select from input to the container
Browse files Browse the repository at this point in the history
This commit fix a testing issue, it does not change anything about
the select component behavior.

react-select does not render our 'input' when the it's not 'searchable'.
-> the aria label definition is put on the container

In order to help for the testing when we have several selects, we want
to have an aria-label, it's define by the placeholder because it's
what the user see (vs the id)
  • Loading branch information
MonPote committed May 7, 2024
1 parent 92217ce commit df92ff4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/lib/components/selectv2/Selectv2.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ export function Option({
}

const Input = (props) => {
const ariaProps = {
role: props.selectProps.isSearchable ? 'combobox' : 'listbox',
'aria-expanded': props.selectProps.menuIsOpen,
'aria-autocomplete': 'list',
};
return <components.Input {...props} {...ariaProps} />;
return <components.Input {...props} />;
};

const selectDropdownIndicator = (
Expand Down Expand Up @@ -285,8 +280,17 @@ const MenuList = (props) => {
const ValueContainer = ({ children, ...props }) => {
const selectedOption = props.selectProps.selectedOption;
const icon = selectedOption ? selectedOption.icon : null;
const ariaProps = {
innerProps: {
role: props.selectProps.isSearchable ? 'combobox' : 'listbox',
'aria-expanded': props.selectProps.menuIsOpen,
'aria-autocomplete': 'list',
'aria-label': props.selectProps.placeholder,
},
};

return (
<components.ValueContainer {...props}>
<components.ValueContainer {...props} {...ariaProps}>
{icon ? <div className="value-container-icon">{icon}</div> : null}
<div>{children}</div>
</components.ValueContainer>
Expand Down

0 comments on commit df92ff4

Please sign in to comment.