Status

()

For bugs in Firefox Desktop, the Mozilla Foundation's web browser. For Firefox user interface issues in menus, bookmarks, location bar, and preferences. Many Firefox bugs will either be filed here or in the Core product. Bugs for developer tools (F12) should be filed in the DevTools product. (more info)

Steps To Reproduce:
1. Open Preferences and sub-dialog
2. Press TAB key several times
Actual Results:
The focus element moves to main preferences which is behind of sub-dialog now
Expected Results:
The focus element should be only in between the browser UI and the sub-dialog

Marco, do you know if there is a sane "web" way to constrain tab selection to items in a given container (element)? Of course, we could steal the tab key, but I'd prefer something that felt less hacky... :-\

Nope, there is only the way of specifically controlling the tab key when it reaches the last element, or the first (when shift-tabbing), and define where it should go next. This is what we get when putting stuff in content that used to be modal, we have to make sure of the modaility ourselves. Every web author faces this when constructing overlays, popups or dialogs and wants to implement full keyboard support.

It seems bug 840640 (the dialog element) and bug 921504 (inert attribute) are relevant here. In the absence of such support, it seems setting tabindex=-1 on all interactive elements except those in the dialog is the necessary workaround.

Summary: Navigating by TAB key, it should be only in between the browser UI and the sub-dialog → In-content prefs should trap focus (tab key navigation) in subdialogs and the browser UI when they are open (it should not be possible to focus items in the main page)

Created attachment 8575997[details][diff][review]
prevent focus from leaving the dialog for anything but the browser UI,
Now with the right window and taking into account the node might be anonymous, esp. for dialog buttons.

Comment on attachment 8575997[details][diff][review]
prevent focus from leaving the dialog for anything but the browser UI,
Review of attachment 8575997[details][diff][review]:
-----------------------------------------------------------------
Built and tested on Windows 8.1 and it works good.
::: browser/components/preferences/in-content/subdialogs.js
@@ +214,3 @@
> this._overlay.style.opacity = ""; // XXX: focus hack continued from _onContentLoaded
> +
> + this._trapFocus();
_untrapFocus is called from _removeDialogEventListeners. It would be nice if _trapFocus was called from _addDialogEventListeners so that we have symmetry.

(In reply to Jared Wein [:jaws] (please needinfo? me) from comment #9)
> Comment on attachment 8575997[details][diff][review]
> prevent focus from leaving the dialog for anything but the browser UI,
>
> Review of attachment 8575997[details][diff][review]:
> -----------------------------------------------------------------
>
> Built and tested on Windows 8.1 and it works good.
>
> ::: browser/components/preferences/in-content/subdialogs.js
> @@ +214,3 @@
> > this._overlay.style.opacity = ""; // XXX: focus hack continued from _onContentLoaded
> > +
> > + this._trapFocus();
>
> _untrapFocus is called from _removeDialogEventListeners. It would be nice if
> _trapFocus was called from _addDialogEventListeners so that we have symmetry.
As discussed on IRC, it needs to have the content document for the frame, that's why it's in onLoad.
Try push, as fx-team is closed anyway:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=abf6376ccbb9