// 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 ) {