fix: fix up/down arrows in poll options (#1934)

fixes #1928
This commit is contained in:
Nolan Lawson 2021-02-14 14:01:46 -08:00 committed by GitHub
parent 6d5bb0e39e
commit 4218c4ce64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,6 +18,17 @@
const elementToKey = element => element.getAttribute('id')
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 {
data: () => ({
activeItemChangeTime: 0,
@ -31,6 +42,9 @@
},
methods: {
onKeyDown (event) {
if (shouldIgnoreEvent(event)) {
return
}
if (event.key === 'j' || event.key === 'ArrowDown') {
event.stopPropagation()
event.preventDefault()