Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
assertNotFocusable,
assertRadioGroupLabel,
getByText,
getRadioGroupLabel,
getRadioGroupOptions,
} from '../../test-utils/accessibility-assertions'
import { html } from '../../test-utils/html'
Expand Down Expand Up @@ -73,6 +74,26 @@ describe('Safe guards', () => {
})
)

it('should not mark the RadioGroupLabel as presentation', async () => {
renderTemplate({
template: html`
<RadioGroup v-model="deliveryMethod">
<RadioGroupLabel>Pizza Delivery</RadioGroupLabel>
<RadioGroupOption value="pickup">Pickup</RadioGroupOption>
<RadioGroupOption value="home-delivery">Home delivery</RadioGroupOption>
</RadioGroup>
`,
setup() {
let deliveryMethod = ref(undefined)
return { deliveryMethod }
},
})

await new Promise<void>(nextTick)

expect(getRadioGroupLabel()).not.toHaveAttribute('role')
})

it('should be possible to render a RadioGroup without options and without crashing', () => {
renderTemplate({
template: html` <RadioGroup v-model="deliveryMethod" /> `,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export let RadioGroup = defineComponent({
let options = ref<StateDefinition['options']['value']>([])
let labelledby = useLabels({ name: 'RadioGroupLabel' })
let describedby = useDescriptions({ name: 'RadioGroupDescription' })
let groupLabelIds = computed(() => new Set((labelledby.value ?? '').split(' ').filter(Boolean)))

expose({ el: radioGroupRef, $el: radioGroupRef })

Expand Down Expand Up @@ -148,6 +149,7 @@ export let RadioGroup = defineComponent({
accept(node) {
if (node.getAttribute('role') === 'radio') return NodeFilter.FILTER_REJECT
if (node.hasAttribute('role')) return NodeFilter.FILTER_SKIP
if (node.id && groupLabelIds.value.has(node.id)) return NodeFilter.FILTER_SKIP
return NodeFilter.FILTER_ACCEPT
},
walk(node) {
Expand Down