feat(a11y): make menu buttons in 'More' dropdown selectable with the keyboard (#2976)

Co-authored-by: userquin <userquin@gmail.com>
This commit is contained in:
jyn 2024-10-21 05:00:51 -04:00 committed by GitHub
parent ae1da4c3e8
commit dac42e062c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 52 additions and 8 deletions

View file

@ -1,16 +1,24 @@
<script setup lang="ts">
const props = withDefaults(defineProps<{
const {
is = 'div',
text,
description,
icon,
checked,
command,
} = defineProps<{
is?: string
text?: string
description?: string
icon?: string
checked?: boolean
command?: boolean
}>(), {
is: 'div',
})
}>()
const emit = defineEmits(['click'])
const type = computed(() => is === 'button' ? 'button' : null)
const { hide } = useDropdownContext() || {}
const el = ref<HTMLDivElement>()
@ -24,11 +32,11 @@ useCommand({
scope: 'Actions',
order: -1,
visible: () => props.command && props.text,
visible: () => command && text,
name: () => props.text!,
icon: () => props.icon ?? 'i-ri:question-line',
description: () => props.description,
name: () => text!,
icon: () => icon ?? 'i-ri:question-line',
description: () => description,
onActivate() {
const clickEvent = new MouseEvent('click', {
@ -46,6 +54,7 @@ useCommand({
v-bind="$attrs"
:is="is"
ref="el"
:type="type"
w-full
flex gap-3 items-center cursor-pointer px4 py3
select-none