Skip to content

Commit 3cb8079

Browse files
authored
update aria-haspopup to use the correct role (#2101)
`aria-haspopup` should now contain the corresponding role instead of just true or false. The `aria-haspopup="true"` is considered a `menu` now. Context: https://w3c.github.io/aria/#aria-haspopup Fixes: #2099
1 parent 962528c commit 3cb8079

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ let Button = forwardRefWithAs(function Button<TTag extends ElementType = typeof
10271027
id,
10281028
type: useResolveButtonType(props, data.buttonRef),
10291029
tabIndex: -1,
1030-
'aria-haspopup': true,
1030+
'aria-haspopup': 'listbox',
10311031
'aria-controls': data.optionsRef.current?.id,
10321032
'aria-expanded': data.disabled ? undefined : data.comboboxState === ComboboxState.Open,
10331033
'aria-labelledby': labelledby,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ let Button = forwardRefWithAs(function Button<TTag extends ElementType = typeof
664664
ref: buttonRef,
665665
id,
666666
type: useResolveButtonType(props, data.buttonRef),
667-
'aria-haspopup': true,
667+
'aria-haspopup': 'listbox',
668668
'aria-controls': data.optionsRef.current?.id,
669669
'aria-expanded': data.disabled ? undefined : data.listboxState === ListboxStates.Open,
670670
'aria-labelledby': labelledby,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ let Button = forwardRefWithAs(function Button<TTag extends ElementType = typeof
371371
ref: buttonRef,
372372
id,
373373
type: useResolveButtonType(props, state.buttonRef),
374-
'aria-haspopup': true,
374+
'aria-haspopup': 'menu',
375375
'aria-controls': state.itemsRef.current?.id,
376376
'aria-expanded': props.disabled ? undefined : state.menuState === MenuStates.Open,
377377
onKeyDown: handleKeyDown,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ export let ComboboxButton = defineComponent({
616616
id,
617617
type: type.value,
618618
tabindex: '-1',
619-
'aria-haspopup': true,
619+
'aria-haspopup': 'listbox',
620620
'aria-controls': dom(api.optionsRef)?.id,
621621
'aria-expanded': api.disabled.value
622622
? undefined

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ export let ListboxButton = defineComponent({
527527
ref: api.buttonRef,
528528
id,
529529
type: type.value,
530-
'aria-haspopup': true,
530+
'aria-haspopup': 'listbox',
531531
'aria-controls': dom(api.optionsRef)?.id,
532532
'aria-expanded': api.disabled.value
533533
? undefined

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export let MenuButton = defineComponent({
317317
ref: api.buttonRef,
318318
id,
319319
type: type.value,
320-
'aria-haspopup': true,
320+
'aria-haspopup': 'menu',
321321
'aria-controls': dom(api.itemsRef)?.id,
322322
'aria-expanded': props.disabled ? undefined : api.menuState.value === MenuStates.Open,
323323
onKeydown: handleKeyDown,

0 commit comments

Comments
 (0)