parent
6d5bb0e39e
commit
4218c4ce64
|
@ -18,6 +18,17 @@
|
||||||
const elementToKey = element => element.getAttribute('id')
|
const elementToKey = element => element.getAttribute('id')
|
||||||
const scope = 'global'
|
const scope = 'global'
|
||||||
|
|
||||||
|
const shouldIgnoreEvent = event => {
|
||||||
|
// For accessibility reasons, do not override the arrowup/arrowdown behavior for radio buttons
|
||||||
|
// (e.g. in a poll). Up/down is supposed to change the radio value, not the current status.
|
||||||
|
const { target, key } = event
|
||||||
|
const isRadio = target &&
|
||||||
|
target.tagName === 'INPUT' &&
|
||||||
|
(target.type || '').toLowerCase() === 'radio'
|
||||||
|
const isArrow = key === 'ArrowUp' || key === 'ArrowDown'
|
||||||
|
return isRadio && isArrow
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
activeItemChangeTime: 0,
|
activeItemChangeTime: 0,
|
||||||
|
@ -31,6 +42,9 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onKeyDown (event) {
|
onKeyDown (event) {
|
||||||
|
if (shouldIgnoreEvent(event)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (event.key === 'j' || event.key === 'ArrowDown') {
|
if (event.key === 'j' || event.key === 'ArrowDown') {
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
Loading…
Reference in a new issue