Fix: provide proper focus order to Category popup

Bug: T257173
Change-Id: I99e9332adb83bf1197da827583b9f22f68b2f395
This commit is contained in:
Akinwale Alagbe 2020-04-01 21:20:54 -07:00 committed by Bartosz Dziewoński
parent cae5f665b8
commit 2f7765d1e8

View file

@ -41,12 +41,15 @@ ve.ui.MWCategoryWidget = function VeUiMWCategoryWidget( config ) {
this.input = new ve.ui.MWCategoryInputWidget( this, { $overlay: config.$overlay } );
this.forceCapitalization = mw.config.get( 'wgCaseSensitiveNamespaces' ).indexOf( categoryNamespace ) === -1;
this.categoryPrefix = mw.config.get( 'wgFormattedNamespaces' )[ categoryNamespace ] + ':';
this.expandedItem = null;
// Events
this.input.connect( this, { choose: 'onInputChoose' } );
this.popup.connect( this, {
removeCategory: 'onRemoveCategory',
updateSortkey: 'onUpdateSortkey'
updateSortkey: 'onUpdateSortkey',
ready: 'onPopupOpened',
closing: 'onPopupClosing'
} );
this.connect( this, {
drag: 'onDrag'
@ -116,6 +119,21 @@ ve.ui.MWCategoryWidget.prototype.onInputChoose = function ( item ) {
}
};
/**
* Hanle popup open event
*
*/
ve.ui.MWCategoryWidget.prototype.onPopupOpened = function () {
this.popup.removeButton.focus();
};
/**
* Handle popup closing dialog
*/
ve.ui.MWCategoryWidget.prototype.onPopupClosing = function () {
this.expandedItem.focus();
};
/**
* Get a category item.
*
@ -213,6 +231,12 @@ ve.ui.MWCategoryWidget.prototype.onTogglePopupMenu = function ( item ) {
// Close open popup.
if ( item.value !== this.popup.category ) {
this.popup.openPopup( item );
this.expandedItem = item;
this.popup
.$element
.attr( 'aria-label',
ve.msg( 'visualeditor-dialog-meta-categories-category' )
);
} else {
// Handle toggle
this.popup.closePopup();