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:
parent
ae1da4c3e8
commit
dac42e062c
3 changed files with 52 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue