Open FADL285 opened 6 months ago
Im having a similar problem and I dont know if this a Vue or HTML problem related, btw I maded a playground showing the behaviour:
When I use the autofocus
on a textarea that will be visible only by a certain condition the console displays this message for me and not focus the textarea
Im having a similar problem and I dont know if this a Vue or HTML problem related, btw I maded a playground showing the behaviour:
When I use the
autofocus
on a textarea that will be visible only by a certain condition the console displays this message for me and not focus the textarea
[EDIT]
I solve this using a custom directive (v-focus):
<template>
<div>
<button @click="shouldShowOnboarding = false">Hide onboarding</button>
<p v-if="shouldShowOnboarding">This is a onboarding message!</p>
<br />
<textarea
v-if="!shouldShowOnboarding"
v-model="content"
v-focus
/>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const content = ref("");
const shouldShowOnboarding = ref(true);
const vFocus = {
mounted: (el: HTMLElement) => el.focus(),
};
</script>
Hi @FADL285,
Did you manage to solve this?
Description
When using the select menu and opening it, this message appears in the console.
Autofocus processing was blocked because a document already has a focused element.