diff --git a/components/settings/SettingsItem.vue b/components/settings/SettingsItem.vue index 324a752b..ed8223a0 100644 --- a/components/settings/SettingsItem.vue +++ b/components/settings/SettingsItem.vue @@ -11,11 +11,28 @@ const props = defineProps<{ large?: true match?: boolean target?: string + button?: boolean }>() +defineEmits<{ + (event: 'click'): void +}>() + +const vm = getCurrentInstance() const router = useRouter() const scrollOnClick = computed(() => props.to && !(props.target === '_blank' || props.external)) +function focus() { + setTimeout(() => { + if (props.button) + vm?.vnode.el?.querySelector('button')?.focus() + else + vm?.vnode.el?.focus() + }, 100) +} + +defineExpose({ focus }) + useCommand({ scope: 'Settings', @@ -45,13 +62,17 @@ useCommand({ exact-active-class="text-primary" :class="disabled ? 'op25 pointer-events-none ' : match ? 'text-primary' : ''" block w-full group focus:outline-none - :tabindex="disabled ? -1 : null" + :tabindex="!button && disabled ? -1 : undefined" + :custom="button" @click="scrollOnClick ? $scrollToTop() : undefined" > -