mediawiki-extensions-Discus.../modules/ModeTabOptionWidget.js
Bartosz Dziewoński 58c078437d Improve mode selector keyboard interactions
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
2021-03-18 15:15:40 +01:00

13 lines
326 B
JavaScript

function ModeTabOptionWidget() {
// Parent constructor
ModeTabOptionWidget.super.apply( this, arguments );
this.$element.addClass( 'ext-discussiontools-ui-modeTab' );
}
OO.inheritClass( ModeTabOptionWidget, OO.ui.TabOptionWidget );
ModeTabOptionWidget.static.highlightable = true;
module.exports = ModeTabOptionWidget;