diff --git a/modules/jquery.wikiEditor.js b/modules/jquery.wikiEditor.js index ac5c38b4..d8f159de 100644 --- a/modules/jquery.wikiEditor.js +++ b/modules/jquery.wikiEditor.js @@ -400,22 +400,27 @@ .attr( 'rel', 'wikiEditor-ui-view-' + options.name ) .addClass( context.view === options.name ? 'current' : null ) .append( $( '' ) - .attr( 'href', '#' ) + .attr( 'tabindex', 0 ) .on( 'mousedown', function () { // No dragging! return false; } ) - .on( 'click', function ( event ) { - context.$ui.find( '.wikiEditor-ui-view' ).hide(); - context.$ui.find( '.' + $( this ).parent().attr( 'rel' ) ).show(); - context.$tabs.find( 'div' ).removeClass( 'current' ); - $( this ).parent().addClass( 'current' ); - $( this ).trigger( 'blur' ); - if ( 'init' in options && typeof options.init === 'function' ) { - options.init( context ); + .on( 'click keydown', function ( event ) { + if ( + event.type === 'click' || + event.type === 'keydown' && event.key === 'Enter' + ) { + context.$ui.find( '.wikiEditor-ui-view' ).hide(); + context.$ui.find( '.' + $( this ).parent().attr( 'rel' ) ).show(); + context.$tabs.find( 'div' ).removeClass( 'current' ); + $( this ).parent().addClass( 'current' ); + $( this ).trigger( 'blur' ); + if ( 'init' in options && typeof options.init === 'function' ) { + options.init( context ); + } + event.preventDefault(); + return false; } - event.preventDefault(); - return false; } ) .text( $.wikiEditor.autoMsg( options, 'title' ) ) ) diff --git a/modules/jquery.wikiEditor.toolbar.config.js b/modules/jquery.wikiEditor.toolbar.config.js index daa868b2..21d286fe 100644 --- a/modules/jquery.wikiEditor.toolbar.config.js +++ b/modules/jquery.wikiEditor.toolbar.config.js @@ -536,11 +536,11 @@ mw.message( 'wikieditor-toolbar-help-content-file-caption' ).text() ] }, result: { html: '
' + - '' + + '' + '' + '' + '
' + - '' + + '' + '
' + mw.message( 'wikieditor-toolbar-help-content-file-caption' ).escaped() + '
' + '
' } diff --git a/modules/jquery.wikiEditor.toolbar.js b/modules/jquery.wikiEditor.toolbar.js index 2443a7e5..f2bddb89 100644 --- a/modules/jquery.wikiEditor.toolbar.js +++ b/modules/jquery.wikiEditor.toolbar.js @@ -308,7 +308,7 @@ } else { $button = $( '' ) .attr( { - href: '#', + tabindex: 0, title: label, rel: id, role: 'button', @@ -347,12 +347,17 @@ ); } ); } else { - $button.on( 'click', function ( e ) { - toolbarModule.fn.doAction( - context, tool.action - ); - e.preventDefault(); - return false; + $button.on( 'click keydown', function ( e ) { + if ( + e.type === 'click' || + e.type === 'keydown' && e.key === 'Enter' + ) { + toolbarModule.fn.doAction( + context, tool.action + ); + e.preventDefault(); + return false; + } } ); } } @@ -373,18 +378,23 @@ e.preventDefault(); return false; } ) - .on( 'click', function ( e ) { - toolbarModule.fn.doAction( - $( this ).data( 'context' ), $( this ).data( 'action' ), $( this ) - ); - // Hide the dropdown - $( this ).closest( '.tool-select' ).removeClass( 'options-shown' ); - e.preventDefault(); - return false; + .on( 'click keydown', function ( e ) { + if ( + e.type === 'click' || + e.type === 'keydown' && e.key === 'Enter' + ) { + toolbarModule.fn.doAction( + $( this ).data( 'context' ), $( this ).data( 'action' ), $( this ) + ); + // Hide the dropdown + $( this ).closest( '.tool-select' ).removeClass( 'options-shown' ); + e.preventDefault(); + return false; + } } ) .text( optionLabel ) .addClass( 'option' ) - .attr( { rel: option, href: '#' } ) + .attr( { rel: option, tabindex: 0 } ) ); } } @@ -392,18 +402,24 @@ .addClass( 'label' ) .text( label ) .data( 'options', $options ) - .attr( 'href', '#' ) + .attr( 'tabindex', 0 ) .on( 'mousedown', function ( e ) { // No dragging! e.preventDefault(); return false; } ) - .on( 'click', function ( e ) { - var $options = $( this ).data( 'options' ); - // eslint-disable-next-line no-jquery/no-class-state - $options.closest( '.tool-select' ).toggleClass( 'options-shown' ); - e.preventDefault(); - return false; + .on( 'click keydown', function ( e ) { + var $options; + if ( + e.type === 'click' || + e.type === 'keydown' && e.key === 'Enter' + ) { + $options = $( this ).data( 'options' ); + // eslint-disable-next-line no-jquery/no-class-state + $options.closest( '.tool-select' ).toggleClass( 'options-shown' ); + e.preventDefault(); + return false; + } } ) ); $select.append( $( '
' ).addClass( 'menu' ).append( $options ) ); @@ -585,7 +601,7 @@ $( '' ) .addClass( selected === id ? 'current' : null ) .attr( { - href: '#', + tabindex: 0, role: 'button', 'aria-pressed': 'false', 'aria-controls': 'wikiEditor-section-' + id @@ -600,7 +616,13 @@ e.preventDefault(); return false; } ) - .on( 'click', function ( e ) { + .on( 'click keydown', function ( e ) { + if ( + e.type !== 'click' && + ( e.type !== 'keydown' || e.key !== 'Enter' ) + ) { + return; + } // We have to set aria-pressed over here, as NVDA wont recognize it // if we do it in the below .each as it seems $( this ).attr( 'aria-pressed', 'true' );