Skip to content

Commit

Permalink
fix(VisuallyHidden): not focusable after native form validation
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia committed Oct 29, 2024
1 parent 30255b6 commit bceefb4
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
8 changes: 5 additions & 3 deletions packages/core/src/Checkbox/Checkbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe('given a default Checkbox', () => {
const wrapper = mount(Checkbox, { attachTo: document.body })
expect(await axe(wrapper.element, {
rules: {
label: { enabled: false },
'label': { enabled: false },
'nested-interactive': { enabled: false },
},
})).toHaveNoViolations()
})
Expand Down Expand Up @@ -120,7 +121,8 @@ describe('given a disabled Checkbox', () => {
it('should have no accessibility violations', async () => {
expect(await axe(wrapper.element, {
rules: {
label: { enabled: false },
'label': { enabled: false },
'nested-interactive': { enabled: false },
},
})).toHaveNoViolations()
})
Expand Down Expand Up @@ -233,7 +235,7 @@ describe('given checkboxGroup in a form', async () => {
})

it('should have hidden input field', async () => {
expect(wrapper.find('input[hidden]').exists()).toBe(true)
expect(wrapper.find('input[data-hidden]').exists()).toBe(true)
})

describe('after clicking submit button', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Combobox/Combobox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ describe('given combobox in a form', async () => {
})

it('should have hidden input field', async () => {
expect(wrapper.find('input[hidden]').exists()).toBe(true)
expect(wrapper.find('input[data-hidden]').exists()).toBe(true)
})

describe('after selecting option and clicking submit button', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Listbox/Listbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ describe('given Listbox in a form', async () => {
})

it('should have hidden input field', async () => {
expect(wrapper.find('input[hidden]').exists()).toBe(true)
expect(wrapper.find('input[data-hidden]').exists()).toBe(true)
})

describe('after selecting option and clicking submit button', () => {
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/Slider/Slider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ describe('given default Slider', () => {

it('should pass axe accessibility tests', async () => {
wrapper = mount(Slider)
expect(await axe(wrapper.element)).toHaveNoViolations()
expect(await axe(wrapper.element, {
rules: {
'label': { enabled: false },
'nested-interactive': { enabled: false },
},
})).toHaveNoViolations()
})

it('should have default value', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/Splitter/Splitter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ describe('test splitter functionalities', () => {
await nextTick()
expect(await axe(wrapper.element, {
rules: {
label: { enabled: false },
'label': { enabled: false },
'nested-interactive': { enabled: false },
},
})).toHaveNoViolations()
})
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/Switch/Switch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ describe('test switch functionalities', () => {
const wrapper = mount(Switch)
expect(await axe(wrapper.element, {
rules: {
label: { enabled: false },
'label': { enabled: false },
'nested-interactive': { enabled: false },
},
})).toHaveNoViolations()
})
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/VisuallyHidden/VisuallyHidden.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ withDefaults(defineProps<VisuallyHiddenProps>(), { as: 'span', feature: 'focusab
:as="as"
:as-child="asChild"
:aria-hidden="feature === 'focusable' ? 'true' : undefined"
:hidden="feature === 'fully-hidden' ? '' : undefined"
:data-hidden="feature === 'fully-hidden' ? '' : undefined"
:tabindex="feature === 'fully-hidden' ? '-1' : undefined"
:style="{
// See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
position: 'absolute',
border: 0,
width: '1px',
display: feature === 'focusable' ? 'inline-block' : 'none',
height: '1px',
padding: 0,
margin: '-1px',
overflow: 'hidden',
clip: 'rect(0, 0, 0, 0)',
clipPath: 'inset(50%)',
whiteSpace: 'nowrap',
wordWrap: 'normal',
}"
Expand Down

0 comments on commit bceefb4

Please # to comment.