Fix an accessibility issue to maximize the panel for all alertify dialog. Fixes #5143

This commit is contained in:
Pradip Parkale
2020-03-06 18:47:22 +05:30
committed by Akshay Joshi
parent 0ed3cd248b
commit 82155cd859
6 changed files with 82 additions and 16 deletions
@@ -8,8 +8,8 @@
//////////////////////////////////////////////////////////////
define([
'sources/gettext', 'alertify', 'jquery',
], function(gettext, alertify, $) {
'sources/gettext', 'alertify', 'jquery', 'sources/utils',
], function(gettext, alertify, $, commonUtils) {
alertify.defaults.transition = 'zoom';
alertify.defaults.theme.ok = 'btn btn-primary fa fa-lg fa-check pg-alertify-button';
alertify.defaults.theme.cancel = 'btn btn-secondary fa fa-lg fa-times pg-alertify-button';
@@ -263,7 +263,15 @@ define([
$(this.elements.commands.close).attr('aria-label', gettext('Close'));
$(this.elements.commands.maximize).attr('aria-label', gettext('Maximize'));
alertifyDialogResized.apply(this, arguments);
});
let self = this;
let cmds = Object.values(this.elements.commands);
$(cmds).on('keydown', 'button', (event) => {
if (event.shiftKey && event.keyCode == 9 && $(this).nextAll('button:not([disabled])').length == 0){
let container = $(self.elements.footer);
commonUtils.findAndSetFocus(container.find('button:not([disabled]):last'));
}
}); });
this.set('onresize', alertifyDialogStartResizing.bind(this, true));
this.set('onresized', alertifyDialogResized.bind(this, true));
this.set('onmaximized', alertifyDialogResized);
@@ -279,6 +287,15 @@ define([
this.__internal.buttons[i]['key'] = null;
}
}
let self = this;
$(this.elements.footer).on('keydown', 'button', function(event) {
if (!event.shiftKey && event.keyCode == 9 && $(this).nextAll('button:not([disabled])').length == 0) {
// set focus back to first editable input element of current active tab once we cycle through all enabled buttons.
commonUtils.findAndSetFocus($(self.elements.dialog));
return false;
}
});
};
alertify.pgHandleItemError = function(xhr, error, message, args) {
@@ -60,14 +60,6 @@ export class DialogWrapper {
this.pgBrowser.keyboardNavigation.getDialogTabNavigator($(alertifyDialog.elements.dialog));
const container = backform_tab.find('.tab-content:first > .tab-pane.active:first');
commonUtils.findAndSetFocus(container);
$(alertifyDialog.elements.footer).on('keydown', 'button', function(event) {
if (event.keyCode == 9 && $(this).nextAll('button:not([disabled])').length == 0) {
// set focus back to first editable input element of current active tab once we cycle through all enabled buttons.
commonUtils.findAndSetFocus($(alertifyDialog.elements.dialog));
return false;
}
});
}
isNodeSelected(selectedTreeNode) {