Merge "ApiSandbox: Blur before sending request"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 26 Feb 2016 18:13:19 +0000 (18:13 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 26 Feb 2016 18:13:19 +0000 (18:13 +0000)
1  2 
resources/src/mediawiki.special/mediawiki.special.apisandbox.js

  
                        // I'm surprised this doesn't seem to exist in jQuery or mw.util.
                        params = {};
 -                      hash = hash.replace( '+', '%20' );
 +                      hash = hash.replace( /\+/g, '%20' );
                        re = /([^&=#]+)=?([^&#]*)/g;
                        while ( ( m = re.exec( hash ) ) ) {
                                params[ decodeURIComponent( m[ 1 ] ) ] = decodeURIComponent( m[ 2 ] );
                 * Submit button handler
                 */
                sendRequest: function () {
-                       var page, subpages, i, query, $result,
+                       var page, subpages, i, query, $result, $focus,
                                progress, $progressText, progressLoading,
                                deferreds = [],
                                params = {},
                                displayParams = {},
                                checkPages = [ pages.main ];
  
+                       // Blur any focused widget before submit, because
+                       // OO.ui.ButtonWidget doesn't take focus itself (T128054)
+                       $focus = $( '#mw-apisandbox-ui' ).find( document.activeElement );
+                       if ( $focus.length ) {
+                               $focus[ 0 ].blur();
+                       }
                        suppressErrors = false;
  
                        while ( checkPages.length ) {