Fixed dialog tab navigation for Backup and Restore dialog. Fixes regression of #3862

pull/20/head
Harshal Dhumal 2019-01-24 17:15:12 +05:30 committed by Akshay Joshi
parent d4fe31404c
commit 42c7ae372f
4 changed files with 17 additions and 7 deletions

View File

@ -8,6 +8,7 @@
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
import * as commonUtils from '../utils'; import * as commonUtils from '../utils';
import $ from 'jquery';
export class DialogWrapper { export class DialogWrapper {
constructor( constructor(
@ -53,11 +54,20 @@ export class DialogWrapper {
return undefined; return undefined;
} }
focusOnDialog(dialog) { focusOnDialog(alertifyDialog) {
dialog.$el.attr('tabindex', -1); let backform_tab = $(alertifyDialog.elements.body).find('.backform-tab');
this.pgBrowser.keyboardNavigation.getDialogTabNavigator(dialog); backform_tab.attr('tabindex', -1);
const container = dialog.$el.find('.tab-content:first > .tab-pane.active:first'); this.pgBrowser.keyboardNavigation.getDialogTabNavigator($(alertifyDialog.elements.dialog));
const container = backform_tab.find('.tab-content:first > .tab-pane.active:first');
commonUtils.findAndSetFocus(container); 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.body).find('.tab-content div.active'));
return false;
}
});
} }
isNodeSelected(selectedTreeNode) { isNodeSelected(selectedTreeNode) {

View File

@ -28,7 +28,7 @@ export function findAndSetFocus(container) {
if (first_el.length == 0) { if (first_el.length == 0) {
first_el = container first_el = container
.find('.pgadmin-controls:first>input:enabled,.CodeMirror-scroll'); .find('.pgadmin-controls:first input:enabled,.CodeMirror-scroll');
} }
if(first_el.length > 0) { if(first_el.length > 0) {

View File

@ -99,7 +99,7 @@ export class BackupDialogWrapper extends DialogWrapper {
this.elements.content.appendChild($container.get(0)); this.elements.content.appendChild($container.get(0));
this.focusOnDialog(dialog); this.focusOnDialog(this);
this.setListenersForFilenameChanges(); this.setListenersForFilenameChanges();
} }

View File

@ -99,7 +99,7 @@ export class RestoreDialogWrapper extends DialogWrapper {
this.elements.content.appendChild($container.get(0)); this.elements.content.appendChild($container.get(0));
this.focusOnDialog(dialog); this.focusOnDialog(this);
this.setListenersForFilenameChanges(); this.setListenersForFilenameChanges();
} }