fix(UnifiedSearch): Focus search input on open

Resolves : https://github.com/nextcloud/server/issues/47056

Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
pull/47319/head
fenn-cs 2024-08-19 07:28:55 +07:00
parent ba9638eae5
commit cf59575120
1 changed files with 10 additions and 3 deletions

@ -304,8 +304,11 @@ export default defineComponent({
watch: {
open() {
// Load results when opened with already filled query
if (this.open && this.searchQuery) {
this.find(this.searchQuery)
if (this.open) {
this.focusInput()
if (this.searchQuery) {
this.find(this.searchQuery)
}
}
},
@ -351,7 +354,11 @@ export default defineComponent({
this.$emit('update:query', this.searchQuery)
this.$emit('update:open', false)
},
focusInput() {
this.$nextTick(() => {
this.$refs.searchInput?.focus()
})
},
find(query: string) {
if (query.length === 0) {
this.results = []