mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-18 19:12:16 +00:00
58c078437d
When there are just two modes, using arrow keys to switch between them is not intuitive. The focus moving from the selector to the body widget afterwards is even less intuitive. Override default TabOptionWidget to allow options to be highlightable (not just immediately selectable), and mark the current mode's tab as disabled instead of selected (but make it look selected). This results in intuitive keyboard interactions (tabbing to the widget highlights the other tab rather than the current one, pressing enter switches to it). Bug: T274423 Change-Id: I9d358d5f301cbf081380ef5d34ccc8c4e146652e
17 lines
480 B
JavaScript
17 lines
480 B
JavaScript
function ModeTabSelectWidget() {
|
|
// Parent constructor
|
|
ModeTabSelectWidget.super.apply( this, arguments );
|
|
}
|
|
|
|
OO.inheritClass( ModeTabSelectWidget, OO.ui.TabSelectWidget );
|
|
|
|
ModeTabSelectWidget.prototype.onDocumentKeyDown = function ( e ) {
|
|
// Handle Space like Enter
|
|
if ( e.keyCode === OO.ui.Keys.SPACE ) {
|
|
e = $.Event( e, { keyCode: OO.ui.Keys.ENTER } );
|
|
}
|
|
ModeTabSelectWidget.super.prototype.onDocumentKeyDown.call( this, e );
|
|
};
|
|
|
|
module.exports = ModeTabSelectWidget;
|