Skip to content

Commit

Permalink
fix(UnifiedSearch): Focus search input on open
Browse files Browse the repository at this point in the history
Resolves : #47056

Signed-off-by: fenn-cs <[email protected]>
  • Loading branch information
Fenn-CS committed Aug 19, 2024
1 parent 551ff49 commit 140dd48
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions core/src/components/UnifiedSearch/UnifiedSearchModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
},
Expand Down Expand Up @@ -351,7 +354,13 @@ export default defineComponent({
this.$emit('update:query', this.searchQuery)
this.$emit('update:open', false)
},
focusInput() {
this.$nextTick(() => {
if (this.$refs.searchInput) {
this.$refs.searchInput.$el.querySelector('input').focus()
}
})
},
find(query: string) {
if (query.length === 0) {
this.results = []
Expand Down

0 comments on commit 140dd48

Please sign in to comment.