mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 322155: if the only focusable elements in a dialog are the buttons, focus the default button on load, r=Neil
This commit is contained in:
parent
101509c76a
commit
5cc9afaeb4
@ -157,22 +157,29 @@
|
||||
<parameter name="aEvent"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var focusInit =
|
||||
function() {
|
||||
// give focus to the first focusable element in the dialog
|
||||
if (!document.commandDispatcher.focusedElement) {
|
||||
document.commandDispatcher.advanceFocusIntoSubtree(document.documentElement);
|
||||
var focusedElt = document.commandDispatcher.focusedElement;
|
||||
if (focusedElt && focusedElt.localName == 'tab') {
|
||||
// We don't want to focus on anonymous OK, Cancel, etc. buttons
|
||||
function focusInit() {
|
||||
// give focus to the first focusable element in the dialog
|
||||
if (!document.commandDispatcher.focusedElement) {
|
||||
document.commandDispatcher.advanceFocusIntoSubtree(document.documentElement);
|
||||
var focusedElt = document.commandDispatcher.focusedElement;
|
||||
if (focusedElt) {
|
||||
if (focusedElt.localName == 'tab') {
|
||||
// Move focus into the tab
|
||||
document.commandDispatcher.advanceFocusIntoSubtree(focusedElt);
|
||||
if (document.commandDispatcher.focusedElement.hasAttribute("dlgtype")) {
|
||||
// Prefer to keep focus on label rather than focus a dialog button
|
||||
// We don't want to focus on anonymous OK, Cancel, etc. buttons,
|
||||
// so return focus to the tab itself
|
||||
focusedElt.focus();
|
||||
}
|
||||
} else {
|
||||
const dialog = document.documentElement;
|
||||
const defaultButton = dialog.getButton(dialog.defaultButton);
|
||||
if (focusedElt.hasAttribute("dlgtype") && focusedElt != defaultButton)
|
||||
defaultButton.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Give focus after onload completes, see bug 103197.
|
||||
setTimeout(focusInit, 0);
|
||||
@ -273,6 +280,7 @@
|
||||
if (aButtons) {
|
||||
// expect a comma delimited list of dlgtype values
|
||||
var list = aButtons.split(",");
|
||||
|
||||
// mark shown dlgtypes as true
|
||||
var shown = { accept: false, cancel: false, help: false,
|
||||
disclosure: false, extra1: false, extra2: false };
|
||||
|
@ -145,22 +145,29 @@
|
||||
<parameter name="aEvent"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var focusInit =
|
||||
function() {
|
||||
// give focus to the first focusable element in the dialog
|
||||
if (!document.commandDispatcher.focusedElement) {
|
||||
document.commandDispatcher.advanceFocusIntoSubtree(document.documentElement);
|
||||
var focusedElt = document.commandDispatcher.focusedElement;
|
||||
if (focusedElt && focusedElt.localName == 'tab') {
|
||||
// We don't want to focus on anonymous OK, Cancel, etc. buttons
|
||||
function focusInit() {
|
||||
// give focus to the first focusable element in the dialog
|
||||
if (!document.commandDispatcher.focusedElement) {
|
||||
document.commandDispatcher.advanceFocusIntoSubtree(document.documentElement);
|
||||
var focusedElt = document.commandDispatcher.focusedElement;
|
||||
if (focusedElt) {
|
||||
if (focusedElt.localName == 'tab') {
|
||||
// Move focus into the tab
|
||||
document.commandDispatcher.advanceFocusIntoSubtree(focusedElt);
|
||||
if (document.commandDispatcher.focusedElement.hasAttribute("dlgtype")) {
|
||||
// Prefer to keep focus on label rather than focus a dialog button
|
||||
// We don't want to focus on anonymous OK, Cancel, etc. buttons,
|
||||
// so return focus to the tab itself
|
||||
focusedElt.focus();
|
||||
}
|
||||
} else {
|
||||
const dialog = document.documentElement;
|
||||
const defaultButton = dialog.getButton(dialog.defaultButton);
|
||||
if (focusedElt.hasAttribute("dlgtype") && focusedElt != defaultButton)
|
||||
defaultButton.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Give focus after onload completes, see bug 103197.
|
||||
setTimeout(focusInit, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user