Skip to content

Commit

Permalink
Trigger mounted event for autocomplete to remove timing dependency (#395
Browse files Browse the repository at this point in the history
)
  • Loading branch information
indykoning authored Dec 12, 2023
1 parent 3b70353 commit 4ab9933
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions resources/js/components/Search/Autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export default {
},
},
mounted() {
this.$nextTick(() => this.$emit('mounted'))
},
render() {
return this.$scopedSlots.default(Object.assign(this, { self: this }))
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
id="autocomplete-input"
placeholder="@lang('Search')"
class="{{ $inputClasses }}"
v-on:focus="$root.loadAutocomplete = true; window.setTimeout(() => window.document.getElementById('autocomplete-input').focus(), 200)"
v-on:focus="$root.loadAutocomplete = true"
v-if="!$root.loadAutocomplete">

<autocomplete
v-if="$root.loadAutocomplete"
v-on:mounted="() => window.document.getElementById('autocomplete-input').focus()"
v-cloak
:additionals="{ categories: ['name^3', 'meta_description^1'] }"
class="w-full"
Expand Down

0 comments on commit 4ab9933

Please sign in to comment.