Skip to content

Commit

Permalink
explicitly add the aria-hidden="true" attribute
Browse files Browse the repository at this point in the history
The `Hidden` component only adds the `aria-hidden` by default if the
`Focusable` feature is passed. In our case we don't want it to be
focusable so therefore we didn't pass this feature flag.

Because we didn't pass the `Focusable` feature, the `display: hidden`
was used which makes it completely unfocusable to the keyboard of the
user which is what we want.

However, the VoiceOver cursor _can_ get into those elements. Adding the
`aria-hidden` manually to these tabs solves the issue.
  • Loading branch information
RobinMalfait committed Aug 28, 2023
1 parent 6444e01 commit 7d3c1ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/@headlessui-react/src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(
}

if (!selected && (theirProps.unmount ?? true) && !(theirProps.static ?? false)) {
return <Hidden as="span" {...ourProps} />
return <Hidden as="span" aria-hidden="true" {...ourProps} />
}

return render({
Expand Down
2 changes: 1 addition & 1 deletion packages/@headlessui-vue/src/components/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ export let TabPanel = defineComponent({
}

if (!selected.value && props.unmount && !props.static) {
return h(Hidden, { as: 'span', ...ourProps })
return h(Hidden, { as: 'span', 'aria-hidden': true, ...ourProps })
}

return render({
Expand Down

0 comments on commit 7d3c1ec

Please sign in to comment.