DLynch has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/252361

Change subject: TitleSearchWidget: Only update results if the query is current
......................................................................

TitleSearchWidget: Only update results if the query is current

With near-simultaneous inputs (e.g. holding down the backspace key
while deleting text) you can cause the suggestion promise to resolve
out-of-order. This causes apparently incorrect suggestions to be
displayed for the current input.

To fix this, check before displaying the results whether the query is
still the same as when the promise was triggered.

Bug: T114178
Change-Id: I9332452fd914b54e7c564284da2a8a00865ae806
---
M resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js
1 file changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/61/252361/1

diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js 
b/resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js
index 0e2546f..884a431 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js
@@ -70,9 +70,17 @@
         * @inheritdoc
         */
        mw.widgets.TitleSearchWidget.prototype.onQueryChange = function () {
-               var widget = this;
+               var query = this.getQueryValue(),
+                       widget = this;
 
                this.getSuggestionsPromise().done( function ( response ) {
+                       if ( widget.getQueryValue() !== query ) {
+                               // The query has changed from the time we 
started. This means that another
+                               // promise will have been fired off anyway. 
Sometimes, because of the joys
+                               // of network operations, these will resolve 
out of order. So, just abandon
+                               // this.
+                               return;
+                       }
                        // Parent method
                        
mw.widgets.TitleSearchWidget.parent.prototype.onQueryChange.call( widget );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/252361
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9332452fd914b54e7c564284da2a8a00865ae806
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to