mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(components): [autocomplete] improve a11y (#12647)
* fix(components): [autocomplete] improve a11y * fix(components): add a11y tests * fix: lint
This commit is contained in:
@@ -440,4 +440,22 @@ describe('Autocomplete.vue', () => {
|
||||
await nextTick()
|
||||
expect(onBlur).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
describe('test a11y supports', () => {
|
||||
test('test a11y attributes', async () => {
|
||||
const wrapper = _mount()
|
||||
await nextTick()
|
||||
|
||||
const container = wrapper.find('.el-autocomplete')
|
||||
expect(container.attributes('role')).toBe('combobox')
|
||||
expect(container.attributes('aria-haspopup')).toBe('listbox')
|
||||
expect(container.attributes('aria-expanded')).toBe('false')
|
||||
|
||||
await wrapper.find('input').trigger('focus')
|
||||
vi.runAllTimers()
|
||||
await nextTick()
|
||||
|
||||
expect(container.attributes('aria-expanded')).toBe('true')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
trigger="click"
|
||||
:transition="`${ns.namespace.value}-zoom-in-top`"
|
||||
persistent
|
||||
role="listbox"
|
||||
@before-show="onSuggestionShow"
|
||||
@hide="onHide"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user