Debounce tag input autocomplete
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
4830750a1d
commit
13fbc9667d
@ -21,7 +21,7 @@
|
||||
maxlength="20"
|
||||
maxtags="10"
|
||||
:placeholder="$t('Eg: Stockholm, Dance, Chess…')"
|
||||
@typing="getFilteredTags"
|
||||
@typing="debouncedGetFilteredTags"
|
||||
:id="id"
|
||||
dir="auto"
|
||||
>
|
||||
@ -33,6 +33,7 @@ import { Component, Prop, Vue } from "vue-property-decorator";
|
||||
import differenceBy from "lodash/differenceBy";
|
||||
import { ITag } from "../../types/tag.model";
|
||||
import { FILTER_TAGS } from "@/graphql/tags";
|
||||
import debounce from "lodash/debounce";
|
||||
|
||||
@Component({
|
||||
apollo: {
|
||||
@ -63,6 +64,12 @@ export default class TagInput extends Vue {
|
||||
return `tag-input-${TagInput.componentId}`;
|
||||
}
|
||||
|
||||
data(): Record<string, unknown> {
|
||||
return {
|
||||
debouncedGetFilteredTags: debounce(this.getFilteredTags, 200),
|
||||
};
|
||||
}
|
||||
|
||||
async getFilteredTags(text: string): Promise<void> {
|
||||
this.text = text;
|
||||
await this.$apollo.queries.tags.refetch();
|
||||
|
Loading…
Reference in New Issue
Block a user