Skip to content

Commit 64b8985

Browse files
authored
fix(dropdown): add aria information to the dropdown component (#3913)
1 parent 0863f54 commit 64b8985

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

packages/renderless/src/dropdown/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const initAria =
179179
({ state, props }: Pick<IDropdownRenderlessParams, 'state' | 'props'>) =>
180180
() => {
181181
state.dropdownElm?.setAttribute('id', state.listId)
182-
state.triggerElm?.setAttribute('aria-haspopup', 'list')
182+
state.triggerElm?.setAttribute('aria-haspopup', 'menu')
183183
state.triggerElm?.setAttribute('aria-controls', state.listId)
184184

185185
if (!props.splitButton || !props.singleButton) {

packages/vue/src/dropdown-item/src/pc.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
@mousedown.stop
3131
:aria-disabled="disabled"
3232
:tabindex="disabled ? null : -1"
33+
role="menuitem"
3334
>
3435
<div class="tiny-dropdown-item__wrap">
3536
<span

packages/vue/src/dropdown-menu/src/pc.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
v-show="state.showPopper"
1919
@mouseenter="handleMouseenter"
2020
@mouseleave="handleMouseleave"
21+
role="menu"
2122
>
2223
<template v-if="state.initShowPopper || state.showPopper">
2324
<slot :selected-index="state.selectedIndex">

packages/vue/src/dropdown/src/pc.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export default defineComponent({
152152
class={`tiny-dropdown__caret-button ${triggerClass}`}
153153
disabled={disabled}
154154
reset-time={0}>
155-
<ButtonIconDown class={visibleClass}></ButtonIconDown>
155+
<ButtonIconDown class={visibleClass} aria-label="down"></ButtonIconDown>
156156
</tiny-button>
157157
</tiny-button-group>
158158
)
@@ -169,7 +169,9 @@ export default defineComponent({
169169
170170
// 增加一层,vue3 环境中无法使用 slots.default 的方式获取原生 DOM 元素
171171
const suffixInner = showIcon ? (
172-
<span class={'tiny-dropdown__suffix-inner ' + visibleClass}>{suffixSlot || <IconDown></IconDown>}</span>
172+
<span class={'tiny-dropdown__suffix-inner ' + visibleClass}>
173+
{suffixSlot || <IconDown aria-label="down"></IconDown>}
174+
</span>
173175
) : (
174176
''
175177
)
@@ -194,15 +196,17 @@ export default defineComponent({
194196
class={`tiny-dropdown__border ${state.visible ? 'is-expand' : ''}${
195197
showIcon ? ' is-show-icon ' : ''
196198
} ${triggerClass}`}
197-
reset-time={0}>
199+
reset-time={0}
200+
aria-label="down">
198201
{prefixInner}
199202
{defaultTriggerElm}
200203
{suffixInner}
201204
</tiny-button>
202205
) : (
203206
<span
204207
ref="trigger"
205-
class={`is-text${state.visible ? ' is-expand' : ' is-hide'}${disabled ? ' is-disabled' : ''} ${triggerClass}`}>
208+
class={`is-text${state.visible ? ' is-expand' : ' is-hide'}${disabled ? ' is-disabled' : ''} ${triggerClass}`}
209+
aria-label="down">
206210
{prefixInner}
207211
{defaultTriggerElm}
208212
{suffixInner}

0 commit comments

Comments
 (0)