Skip to content
This repository was archived by the owner on Aug 2, 2024. It is now read-only.

Commit f54364c

Browse files
fix: dynamic completions
1 parent 8abe2fe commit f54364c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/components/SearchInput/SearchInput.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@ export default {
217217
}
218218
},
219219
watch: {
220+
// We observe the completions that currently match the predicate and if there are any matches
221+
// and the input element is focused we show the completion list.
222+
// TODO: Add tests
223+
// TODO: Make activeElement and "isFocusedAndHasMatchingCompletions" reactive and
224+
// bind the visibility of the completions list to isFocusedAndHasMatchingCompletions
225+
completionsMatchingPredicate(completionsMatchingPredicate) {
226+
if (completionsMatchingPredicate != null && completionsMatchingPredicate.length > 0) {
227+
if (document.activeElement === this.$refs.input.$el) {
228+
this.showCompletions();
229+
}
230+
}
231+
},
220232
predicate: {
221233
immediate: true,
222234
handler(newValue) {

0 commit comments

Comments
 (0)