Fix search input failing to focus after adding filter (#2023)

This commit is contained in:
bymyself
2024-12-23 07:27:17 -07:00
committed by GitHub
parent cf51254d24
commit 9f6c828cfe
3 changed files with 40 additions and 6 deletions

View File

@@ -65,7 +65,7 @@
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { computed, nextTick, onMounted, ref } from 'vue'
import AutoCompletePlus from '@/components/primevueOverride/AutoCompletePlus.vue'
import Dialog from 'primevue/dialog'
import Button from 'primevue/button'
@@ -124,11 +124,12 @@ const search = (query: string) => {
const emit = defineEmits(['addFilter', 'removeFilter', 'addNode'])
let inputElement: HTMLInputElement | null = null
const reFocusInput = () => {
const inputElement = document.getElementById(inputId) as HTMLInputElement
inputElement ??= document.getElementById(inputId) as HTMLInputElement
if (inputElement) {
inputElement.blur()
inputElement.focus()
nextTick(() => inputElement?.focus())
}
}