Skip to content

Commit

Permalink
fix(machines): select uses the correct id for `aria-activedecesenda…
Browse files Browse the repository at this point in the history
…nt` field (#1215)

* fix(machines): use correct highlightedValue id on select machine

* fix(machines): use undefined for empty highlighted value

* docs: changeset

---------

Co-authored-by: Segun Adebayo <[email protected]>
  • Loading branch information
remonke and segunadebayo authored Feb 4, 2024
1 parent 76c1231 commit fa82362
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wild-drinks-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zag-js/select": patch
---

Fix issue where select uses the incorrect `id` for `aria-activedecesendant` field
4 changes: 3 additions & 1 deletion packages/machines/select/src/select.connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ export function connect<T extends PropTypes, V extends CollectionItem = Collecti
role: "listbox",
...parts.content.attrs,
"data-state": isOpen ? "open" : "closed",
"aria-activedescendant": state.context.highlightedValue || "",
"aria-activedescendant": state.context.highlightedValue
? dom.getItemId(state.context, state.context.highlightedValue)
: undefined,
"aria-multiselectable": state.context.multiple ? "true" : undefined,
"aria-labelledby": dom.getLabelId(state.context),
tabIndex: 0,
Expand Down

0 comments on commit fa82362

Please sign in to comment.