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(MultiSelect): adds and updates list item aria, fixes type bug w/ itemToString #7889

Merged
merged 2 commits into from
Feb 25, 2021
Merged
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
8 changes: 7 additions & 1 deletion packages/react/src/components/MultiSelect/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ const MultiSelect = React.forwardRef(function MultiSelect(
...downshiftProps,
highlightedIndex,
isOpen,
itemToString,
itemToString: (items) => {
return items.map((item) => itemToString(item)).join(', ');
},
onStateChange,
selectedItem: controlledSelectedItems,
items,
Expand Down Expand Up @@ -245,6 +247,9 @@ const MultiSelect = React.forwardRef(function MultiSelect(
sortItems(items, sortOptions).map((item, index) => {
const itemProps = getItemProps({
item,
// we don't want Downshift to set aria-selected for us
// we also don't want to set 'false' for reader verbosity's sake
['aria-selected']: isChecked ? true : null,
});
const itemText = itemToString(item);
const isChecked =
Expand All @@ -254,6 +259,7 @@ const MultiSelect = React.forwardRef(function MultiSelect(
<ListBox.MenuItem
key={itemProps.id}
isActive={isChecked}
aria-label={itemText}
isHighlighted={highlightedIndex === index}
title={itemText}
{...itemProps}>
Expand Down