]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7232 Search results are wrong when two almost simultaneous requests are sent
authorStas Vilchik <vilchiks@gmail.com>
Thu, 14 Apr 2016 08:16:04 +0000 (10:16 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 14 Apr 2016 08:40:14 +0000 (10:40 +0200)
server/sonar-web/src/main/js/main/nav/global/search-view.js

index 7dba2f34a5deb2392b7c3d9d05979ff0d9b5f66b..e88f381201cbb23709c7fb83fb6ebb08e5d790f9 100644 (file)
@@ -142,9 +142,6 @@ export default Marionette.LayoutView.extend({
       return;
     }
     this._bufferedValue = this.$('.js-search-input').val();
-    if (this.searchRequest != null && this.searchRequest.abort != null) {
-      this.searchRequest.abort();
-    }
     this.searchRequest = this.debouncedSearch(value);
   },
 
@@ -201,6 +198,12 @@ export default Marionette.LayoutView.extend({
     const url = window.baseUrl + '/api/components/suggestions';
     const options = { s: q };
     return $.get(url, options).done(function (r) {
+      // if the input value has changed since we sent the request,
+      // just ignore the output, because another request already sent
+      if (q !== that._bufferedValue) {
+        return;
+      }
+
       const collection = [];
       r.results.forEach(function (domain) {
         domain.items.forEach(function (item, index) {