mediawiki.widgets: Add temporary workaround for upstream oojs-ui bug
authorEd Sanders <esanders@wikimedia.org>
Mon, 28 Sep 2015 15:28:09 +0000 (16:28 +0100)
committerEd Sanders <esanders@wikimedia.org>
Mon, 28 Sep 2015 15:30:40 +0000 (16:30 +0100)
'choose' sometimes emits with null. Fixed upstream in I03f0b6d88f.

Change-Id: I4f5ab119555f9e3c439e3d91054b8b99d0dd89a5

resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js

index 0e2546f..c37c723 100644 (file)
         * @param {OO.ui.OptionWidget} item Chosen item
         */
        mw.widgets.TitleSearchWidget.prototype.onTitleSearchResultsChoose = function ( item ) {
-               this.getQuery().setValue( item.getData() );
+               // TOOD: Pressing enter can incorrectly trigger 'choose' with null.
+               // Remove this check when oojs-ui 0.12.10 lands.
+               if ( item ) {
+                       this.getQuery().setValue( item.getData() );
+               }
        };
 
        /**