Skip to content

Commit

Permalink
Fix intermittent searchbar_spec.js test failure
Browse files Browse the repository at this point in the history
We need to wait for search results before sending new ones, or we end up
skipping over valid results.

Signed-off-by: Chris Lord <chris.lord@collabora.com>
Change-Id: I957873ee8c80ac8c1ed04a33510b3c6b46886360
  • Loading branch information
Chris Lord authored and mmeeks committed Nov 22, 2024
1 parent d09dee6 commit df011e4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions browser/src/control/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,25 @@
/* global app */

L.Map.include({
_onSearch: function() {
this.off('search', this._onSearch, this);
if (this._pendingSearch) {
this.search.bind(this, ...this._pendingSearch)();
this._pendingSearch = null;
}
},

search: function (text, backward, replaceString, command, expand) {
if (this._docLayer._searchRequested) {
// If we're waiting for a search result, wait for the response before
// sending a new one.
// This reduces traffic and also avoids the bug where fast successive
// searches can skip over results.
this.on('search', this._onSearch, this);
this._pendingSearch = arguments;
return;
}

if (backward === undefined) {
backward = false;
}
Expand Down

0 comments on commit df011e4

Please sign in to comment.