Skip to content

Commit 7ecf832

Browse files
authored
Move aria-multiselectable to [role=listbox] in the Combobox component (#2271)
* move `aria-multiselectable` to `[role=listbox]` in the `Combobox` component * update changelog
1 parent 0ff2326 commit 7ecf832

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

packages/@headlessui-react/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Ensure we handle `null` dataRef values correctly ([#2258](https://github.com/tailwindlabs/headlessui/pull/2258))
13+
- Move `aria-multiselectable` to `[role=listbox]` in the `Combobox` component ([#2271](https://github.com/tailwindlabs/headlessui/pull/2271))
1314

1415
## [1.7.10] - 2023-02-06
1516

packages/@headlessui-react/src/components/combobox/combobox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,6 @@ let Input = forwardRefWithAs(function Input<
938938
'aria-expanded': data.disabled ? undefined : data.comboboxState === ComboboxState.Open,
939939
'aria-activedescendant':
940940
data.activeOptionIndex === null ? undefined : data.options[data.activeOptionIndex]?.id,
941-
'aria-multiselectable': data.mode === ValueMode.Multi ? true : undefined,
942941
'aria-labelledby': labelledby,
943942
'aria-autocomplete': 'list',
944943
defaultValue:
@@ -1186,6 +1185,7 @@ let Options = forwardRefWithAs(function Options<
11861185
let ourProps = {
11871186
'aria-labelledby': labelledby,
11881187
role: 'listbox',
1188+
'aria-multiselectable': data.mode === ValueMode.Multi ? true : undefined,
11891189
id,
11901190
ref: optionsRef,
11911191
}

packages/@headlessui-react/src/test-utils/accessibility-assertions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ export function assertCombobox(
281281
state: ComboboxState
282282
mode?: ComboboxMode
283283
},
284-
combobox = getComboboxInput()
284+
combobox = getComboboxInput(),
285+
listbox = getListbox()
285286
) {
286287
try {
287288
switch (options.state) {
@@ -307,7 +308,7 @@ export function assertCombobox(
307308
expect(combobox).toHaveAttribute('role', 'combobox')
308309

309310
if (options.mode && options.mode === ComboboxMode.Multiple) {
310-
expect(combobox).toHaveAttribute('aria-multiselectable', 'true')
311+
expect(listbox).toHaveAttribute('aria-multiselectable', 'true')
311312
}
312313

313314
if (options.textContent) expect(combobox).toHaveTextContent(options.textContent)

packages/@headlessui-vue/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Don’t fire `afterLeave` event more than once for a given transition ([#2267](https://github.com/tailwindlabs/headlessui/pull/2267))
13+
- Move `aria-multiselectable` to `[role=listbox]` in the `Combobox` component ([#2271](https://github.com/tailwindlabs/headlessui/pull/2271))
1314

1415
## [1.7.9] - 2023-02-03
1516

packages/@headlessui-vue/src/components/combobox/combobox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,6 @@ export let ComboboxInput = defineComponent({
907907
api.activeOptionIndex.value === null
908908
? undefined
909909
: api.options.value[api.activeOptionIndex.value]?.id,
910-
'aria-multiselectable': api.mode.value === ValueMode.Multi ? true : undefined,
911910
'aria-labelledby': dom(api.labelRef)?.id ?? dom(api.buttonRef)?.id,
912911
'aria-autocomplete': 'list',
913912
id,
@@ -990,6 +989,7 @@ export let ComboboxOptions = defineComponent({
990989
id,
991990
ref: api.optionsRef,
992991
role: 'listbox',
992+
'aria-multiselectable': api.mode.value === ValueMode.Multi ? true : undefined,
993993
}
994994
let theirProps = omit(props, ['hold'])
995995

packages/@headlessui-vue/src/test-utils/accessibility-assertions.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ export function assertCombobox(
281281
state: ComboboxState
282282
mode?: ComboboxMode
283283
},
284-
combobox = getComboboxInput()
284+
combobox = getComboboxInput(),
285+
listbox = getListbox()
285286
) {
286287
try {
287288
switch (options.state) {
@@ -307,7 +308,7 @@ export function assertCombobox(
307308
expect(combobox).toHaveAttribute('role', 'combobox')
308309

309310
if (options.mode && options.mode === ComboboxMode.Multiple) {
310-
expect(combobox).toHaveAttribute('aria-multiselectable', 'true')
311+
expect(listbox).toHaveAttribute('aria-multiselectable', 'true')
311312
}
312313

313314
if (options.textContent) expect(combobox).toHaveTextContent(options.textContent)

0 commit comments

Comments
 (0)