jenkins-bot has submitted this change and it was merged.
Change subject: $.suggester: Correctly handling arrays of objects passed as
source
......................................................................
$.suggester: Correctly handling arrays of objects passed as source
When defining an array as source, the parent $.ui.autocomplete requires either
an
array of plain strings or an array of objects featuring the attributes "label"
and
"value".
Change-Id: Ibebb79554548084d68cfb014a26adc770d46cb7d
---
M ValueView/resources/jquery.ui/jquery.ui.suggester.js
1 file changed, 8 insertions(+), 3 deletions(-)
Approvals:
Addshore: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ValueView/resources/jquery.ui/jquery.ui.suggester.js
b/ValueView/resources/jquery.ui/jquery.ui.suggester.js
index 163f417..ac3a845 100644
--- a/ValueView/resources/jquery.ui/jquery.ui.suggester.js
+++ b/ValueView/resources/jquery.ui/jquery.ui.suggester.js
@@ -225,11 +225,16 @@
* @param {Function} response
*/
_filterArray: function( request, response ) {
- var resultSet = $.ui.autocomplete.filter(
this.options.source, request.term );
+ var resultSet = $.ui.autocomplete.filter(
this.options.source, request.term ),
+ firstLabel = resultSet[0];
+
+ if( $.isPlainObject( resultSet[0] ) ) {
+ firstLabel = resultSet[0].label;
+ }
if ( resultSet.length && this.options.adaptLetterCase )
{
this.term = $.util.adaptLetterCase( this.term,
- resultSet[0],
+ firstLabel,
this.options.adaptLetterCase
);
this.element.val( this.term );
@@ -238,7 +243,7 @@
response( resultSet );
if( this._lastKeyDown !== $.ui.keyCode.BACKSPACE ) {
- this.element.autocompletestring( request.term,
resultSet[0] );
+ this.element.autocompletestring( request.term,
firstLabel );
}
},
--
To view, visit https://gerrit.wikimedia.org/r/96499
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibebb79554548084d68cfb014a26adc770d46cb7d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits