Debounce tag input autocomplete

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
chapril
Thomas Citharel 9 months ago
parent b47e46cef5
commit 85f8450a85
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
  1. 9
      js/src/components/Event/TagInput.vue

@ -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…
Cancel
Save