Skip to content

Commit

Permalink
为 RegionPicker 添加键盘导航 & WAI-ARIA 支持 (#303)
Browse files Browse the repository at this point in the history
* support focus outside
* keyboard nav & WAI-ARIA support for `RegionPicker`
* `log10` in `utils/math`
* `focusBefore` & `focusAfter` in `utils/dom`
* `focus({ visible })` for `Radio` & `Checkbox`
* omit delay arg if delay is 0
  • Loading branch information
Justineo authored May 2, 2018
1 parent 25bf7dd commit e750248
Show file tree
Hide file tree
Showing 10 changed files with 327 additions and 72 deletions.
6 changes: 3 additions & 3 deletions packages/veui-theme-one/components/region-picker.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
border: 1px solid @veui-gray-color-5;

&-section {
border-top: 1px solid @veui-gray-color-5;
border-bottom: 1px solid @veui-gray-color-5;

&:first-child {
border-top: none;
&:last-child {
border-bottom: none;
}

&-title {
Expand Down
2 changes: 1 addition & 1 deletion packages/veui/src/components/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default {
if (event === 'click') {
setTimeout(() => {
this.$refs.item[this.localIndex].focus()
}, 0)
})
}
this.localIndex = index
Expand Down
9 changes: 8 additions & 1 deletion packages/veui/src/components/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Icon from './Icon'
import input from '../mixins/input'
import ui from '../mixins/ui'
import { getListeners } from '../utils/helper'
import { patchIndeterminate } from '../utils/dom'
import { patchIndeterminate, focus } from '../utils/dom'
const EVENTS = ['keyup', 'keydown', 'keypress', 'focus', 'blur']
Expand Down Expand Up @@ -93,6 +93,13 @@ export default {
},
toggleChecked () {
this.localChecked = this.isChecked ? this.falseValue : this.trueValue
},
focus ({ visible = false }) {
if (visible) {
focus(this.$refs.box)
} else {
this.$refs.box.focus()
}
}
},
watch: {
Expand Down
11 changes: 11 additions & 0 deletions packages/veui/src/components/Radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
}"
:ui="ui">
<input
ref="box"
type="radio"
v-bind="attrs"
@change="localChecked = $event.target.checked"
Expand All @@ -19,6 +20,7 @@
import ui from '../mixins/ui'
import input from '../mixins/input'
import { getListeners } from '../utils/helper'
import { focus } from '../utils/dom'
const EVENTS = ['keyup', 'keydown', 'keypress', 'focus', 'blur']
Expand Down Expand Up @@ -83,6 +85,15 @@ export default {
},
immediate: true
}
},
methods: {
focus ({ visible = false }) {
if (visible) {
focus(this.$refs.box)
} else {
this.$refs.box.focus()
}
}
}
}
</script>
Loading

0 comments on commit e750248

Please sign in to comment.