Fix jumping to top of page when opening menu

I also thought this would maybe fix one of the focustrap errors in the console, but no.
This commit is contained in:
Freeplay 2023-04-30 11:58:36 -04:00
parent d1cdd58bc1
commit affeb55c01

View file

@ -1,6 +1,6 @@
<template> <template>
<FocusTrap v-bind:active="isActive"> <FocusTrap :active="false" ref="focusTrap">
<div tabindex="-1" v-focus> <div tabindex="-1">
<div <div
ref="itemsEl" ref="itemsEl"
class="rrevdjwt _popup _shadow" class="rrevdjwt _popup _shadow"
@ -206,6 +206,7 @@ import { i18n } from "@/i18n";
import { FocusTrap } from 'focus-trap-vue'; import { FocusTrap } from 'focus-trap-vue';
const XChild = defineAsyncComponent(() => import("./MkMenu.child.vue")); const XChild = defineAsyncComponent(() => import("./MkMenu.child.vue"));
const focusTrap = ref();
const props = defineProps<{ const props = defineProps<{
items: MenuItem[]; items: MenuItem[];
@ -316,6 +317,8 @@ function focusDown() {
} }
onMounted(() => { onMounted(() => {
focusTrap.value.activate();
if (props.viaKeyboard) { if (props.viaKeyboard) {
nextTick(() => { nextTick(() => {
focusNext(itemsEl.children[0], true, false); focusNext(itemsEl.children[0], true, false);