Commit 2fbe636b52548f287bb696daf9e9c279a1383232
1 parent
2c6b8f09
Select support a part of keyboard accessibility, #1647
Showing
2 changed files
with
15 additions
and
1 deletions
Show diff stats
src/components/select/select.vue
1 | <template> | 1 | <template> |
2 | - <div :class="classes" v-clickoutside="handleClose"> | 2 | + <div |
3 | + tabindex="0" | ||
4 | + @keydown.down="handleFocus" | ||
5 | + :class="classes" | ||
6 | + v-clickoutside="handleClose"> | ||
3 | <div | 7 | <div |
4 | :class="selectionCls" | 8 | :class="selectionCls" |
5 | ref="reference" | 9 | ref="reference" |
@@ -260,6 +264,10 @@ | @@ -260,6 +264,10 @@ | ||
260 | } | 264 | } |
261 | }, | 265 | }, |
262 | methods: { | 266 | methods: { |
267 | + // open when focus on Select and press `down` key | ||
268 | + handleFocus () { | ||
269 | + if (!this.visible) this.toggleMenu(); | ||
270 | + }, | ||
263 | toggleMenu () { | 271 | toggleMenu () { |
264 | if (this.disabled || this.autoComplete) { | 272 | if (this.disabled || this.autoComplete) { |
265 | return false; | 273 | return false; |
src/styles/components/select.less
@@ -55,6 +55,12 @@ | @@ -55,6 +55,12 @@ | ||
55 | transform: rotate(180deg); | 55 | transform: rotate(180deg); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | + &:focus{ | ||
59 | + outline: 0; | ||
60 | + .@{select-prefix-cls}-selection{ | ||
61 | + .active(); | ||
62 | + } | ||
63 | + } | ||
58 | 64 | ||
59 | &-disabled { | 65 | &-disabled { |
60 | .@{select-prefix-cls}-selection { | 66 | .@{select-prefix-cls}-selection { |