Merge pull request #47319 from nextcloud/fix/47056/focus-unified-search-on-open

fix(UnifiedSearch): Focus search input on open
pull/47331/head
F. E Noel Nfebe 2024-08-19 19:30:16 +07:00 committed by GitHub
commit 3b795cde79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 6 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 = []

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long