Skip to content

Commit bfc7549

Browse files
committed
fix(select): add some aria-* props for ai
1 parent 7fee047 commit bfc7549

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

packages/renderless/src/select/vue.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ const initState = ({
296296
content: state.displayOnlyContent,
297297
always: !!state.displayOnlyContent,
298298
...props.tooltipConfig
299-
}))
299+
})),
300+
ariaListId: 'tiny-select-' + crypto.randomUUID().slice(-8)
300301
})
301302

302303
return state

packages/vue/src/option/src/mobile-first.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
)
2222
"
2323
data-tag="tiny-option"
24+
role="option"
25+
:aria-label="state.currentLabel"
26+
:aria-selected="state.itemSelected"
2427
>
2528
<span v-if="state.selectMultiple" class="w-4 mr-2">
2629
<component

packages/vue/src/option/src/pc.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
},
1818
highlightClass
1919
]"
20+
role="option"
21+
:aria-label="state.currentLabel"
22+
:aria-selected="state.itemSelected"
2023
>
2124
<span v-if="state.selectMultiple" class="tiny-option__checkbox-wrap tiny-select-dropdown__item-checkbox">
2225
<component :is="`icon-${state.selectCls}`" :class="`tiny-svg-size ${state.selectCls}`" />

packages/vue/src/select/src/mobile-first.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@
245245
'max-width': state.inputWidth - 42 + 'px',
246246
height: 'auto'
247247
}"
248+
role="combobox"
249+
aria-haspopup="listbox"
250+
aria-autocomplete="list"
251+
:aria-owns="state.ariaListId"
252+
:aria-controls="state.ariaListId"
248253
/>
249254
</div>
250255
<tiny-input
@@ -277,6 +282,11 @@
277282
@mouseenter="onMouseenterNative"
278283
@mouseleave="onMouseleaveNative"
279284
@compositionend.native="handleComposition"
285+
role="combobox"
286+
aria-haspopup="listbox"
287+
aria-autocomplete="list"
288+
:aria-owns="state.ariaListId"
289+
:aria-controls="state.ariaListId"
280290
>
281291
<template #prefix v-if="slots.prefix">
282292
<slot name="prefix"></slot>
@@ -340,6 +350,8 @@
340350
:popper-options="popperOptions"
341351
:class="m('duration-300')"
342352
:height="dropdownHeight"
353+
role="listbox"
354+
:id="state.ariaListId"
343355
>
344356
<div
345357
v-if="shape && filterable"
@@ -451,7 +463,10 @@
451463
<component
452464
:is="`icon-${state.selectCls}`"
453465
:class="
454-
m(['-mt-0.5 mr-2 fill-color-icon-secondary w-3.5 h-3.5 ', state.selectCls !== 'check' && 'fill-color-brand text-color-brand'])
466+
m([
467+
'-mt-0.5 mr-2 fill-color-icon-secondary w-3.5 h-3.5 ',
468+
state.selectCls !== 'check' && 'fill-color-brand text-color-brand'
469+
])
455470
"
456471
/>
457472
<span :class="[state.selectCls === 'checked-sur' ? 'text-color-brand' : 'text-color-text-primary']">

packages/vue/src/select/src/pc.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@
294294
@mouseenter="onMouseenterNative"
295295
@mouseleave="onMouseleaveNative"
296296
@compositionend.native="handleComposition"
297+
role="combobox"
298+
aria-haspopup="listbox"
299+
aria-autocomplete="list"
300+
:aria-owns="state.ariaListId"
301+
:aria-controls="state.ariaListId"
297302
>
298303
<template #prefix v-if="slots.prefix">
299304
<slot name="prefix"></slot>
@@ -354,6 +359,8 @@
354359
v-show="!onCopying() && !hideDrop && state.visible && state.emptyText !== false"
355360
:style="dropStyle"
356361
:popper-options="popperOptions"
362+
role="listbox"
363+
:id="state.ariaListId"
357364
>
358365
<div
359366
v-if="shape && filterable"

0 commit comments

Comments
 (0)