diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/AddPersons.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/AddPersons.js index d72a42b15..453c2674a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/AddPersons.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/AddPersons.js @@ -45,7 +45,7 @@ const searchPersons = ({ query, options }, signal) => { const searchEntities = ({ query, options }, signal) => { let queryStr = parametersToString({ query, options }); let url = `/api/1.0/search.json?${queryStr}`; - return fetch(url) + return fetch(url, { signal }) .then(response => { if (response.ok) { return response.json(); } throw Error('Error with request resource response'); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue index 37707155d..90505a1e2 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue @@ -199,15 +199,26 @@ export default { return; } if (query === this.search.query) { - if (this.currentSearchQueryController !== undefined) { - this.currentSearchQueryController.abort() + if (this.search.currentSearchQueryController !== null) { + this.search.currentSearchQueryController.abort(); } - this.currentSearchQueryController = new AbortController(); - searchEntities({ query, options: this.options }, this.currentSearchQueryController) - .then(suggested => new Promise((resolve, reject) => { - this.loadSuggestions(suggested.results); - resolve(); - })); + this.search.currentSearchQueryController = new AbortController(); + searchEntities({ query, options: this.options }, this.search.currentSearchQueryController.signal) + .then(suggested => new Promise((resolve, reject) => { + this.loadSuggestions(suggested.results); + resolve(); + })) + .catch(error => { + if (error instanceof DOMException) { + if (error.name === 'AbortError') { + console.log('request aborted due to user continue typing'); + return; + } + } + + throw error; + }) + ; } }.bind(this), query.length > 3 ? 300 : 700); },