mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-01 21:15:00 +02:00
Update using keyboard controls to toggle checkboxes and show outline when buttons are focused #4140
This commit is contained in:
parent
92bb3527de
commit
89d0257a76
2 changed files with 15 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<label class="flex justify-start items-center" :class="!disabled ? 'cursor-pointer' : ''">
|
||||
<label tabindex="0" ref="labelRef" class="flex justify-start items-center" :class="!disabled ? 'cursor-pointer' : ''" @keydown.enter="enterKeydown">
|
||||
<div class="border-2 rounded flex flex-shrink-0 justify-center items-center" :class="wrapperClass">
|
||||
<input v-model="selected" :disabled="disabled" type="checkbox" :aria-label="ariaLabel" class="opacity-0 absolute" :class="!disabled ? 'cursor-pointer' : ''" />
|
||||
<input v-model="selected" tabindex="-1" :disabled="disabled" type="checkbox" :aria-label="ariaLabel" class="opacity-0 absolute" :class="!disabled ? 'cursor-pointer' : ''" />
|
||||
<span v-if="partial" class="material-symbols text-base leading-none text-gray-400">remove</span>
|
||||
<svg v-else-if="selected" class="fill-current pointer-events-none" :class="svgClass" viewBox="0 0 20 20"><path d="M0 11l2-2 5 5L18 3l2 2L7 18z" /></svg>
|
||||
</div>
|
||||
|
@ -76,7 +76,17 @@ export default {
|
|||
return classes.join(' ')
|
||||
}
|
||||
},
|
||||
methods: {},
|
||||
methods: {
|
||||
enterKeydown() {
|
||||
// Only toggle checkbox if label is focused (from tabbing)
|
||||
if (document.activeElement === this.$refs.labelRef) {
|
||||
this.toggleCheckbox()
|
||||
}
|
||||
},
|
||||
toggleCheckbox() {
|
||||
if (!this.disabled) this.selected = !this.selected
|
||||
}
|
||||
},
|
||||
mounted() {}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue