Skip to content

Commit

Permalink
Filter select aria label fix (#5122)
Browse files Browse the repository at this point in the history
* update aria-properties to ensure correct label is passed into ListBox
* add changeset
  • Loading branch information
mcwinter07 authored Oct 3, 2024
1 parent 7aeab2d commit 27706c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-goats-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kaizen/components": patch
---

Add accessible label fix for selects
12 changes: 9 additions & 3 deletions packages/components/src/Filter/FilterSelect/FilterSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ export const FilterSelect = <Option extends SelectOption = SelectOption>({
)

const { buttonProps } = useButton(triggerProps, triggerRef)

const renderTriggerButtonProps = {
...buttonProps,
"aria-labelledby": undefined,
"aria-controls": menuProps.id,
}
return (
<>
<HiddenSelect label={label} state={state} triggerRef={triggerRef} />
Expand All @@ -90,15 +94,17 @@ export const FilterSelect = <Option extends SelectOption = SelectOption>({
selectedValue: state.selectedItem?.textValue || undefined,
label,
isOpen,
...buttonProps,
...renderTriggerButtonProps,
})
}
onMount={setTriggerRef}
classNameOverride={classNameOverride}
>
<FilterContents classNameOverride={styles.filterContents}>
<SelectProvider<Option> state={state}>
<SelectPopoverContents menuProps={menuProps}>
<SelectPopoverContents
menuProps={{ ...menuProps, "aria-labelledby": buttonProps.id }}
>
{children}
</SelectPopoverContents>
</SelectProvider>
Expand Down

0 comments on commit 27706c6

Please sign in to comment.