bugzilla.mozilla.org will be intermittently unavailable on Saturday, March 24th, from 16:00 until 20:00 UTC.

Switching tabs in a tabbox can result in illogical assignment of focus

RESOLVED FIXED in mozilla1.8.1



XUL Widgets
12 years ago
12 years ago


(Reporter: Tim Martin, Assigned: Nickolay_Ponomarev)


({fixed1.8.1, testcase})

1.8 Branch
fixed1.8.1, testcase

Firefox Tracking Flags

(Not tracked)




(2 attachments, 1 obsolete attachment)



12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5

If the current tab does not have focus, selecting another causes the next item in the tabring to gain focus.  If the new tab doesn't contain any focusable elements, focus will be assigned to an item outside the tabbox.  This can even cause the location bar to gain focus, which is especially illogical (and causes additional problems; see Bug 320427).

Note that, in the test case, switching from tab B to tab A will cause the textbox in tabpanel A to gain focus, which probably makes sense.  But because tab B doesn't contain such an element, Firefox just focuses on the next available item outside of the tabbox, which can surprise the user.

If, when switching tabs, the current tab element has focus, then focus is transferred to the new tab, and that should probably be the behavior when there's no focusable element in a tab.

Reproducible: Always

Steps to Reproduce:
1. Open the testcase XUL file
2. Focus on something which is not tab A (such as the textbox)
3. Click on another tab

Actual Results:  
The next item after the tabbox gains focus.

Expected Results:  
If a tab contains no elements which can gain focus, the tab element should probably get focus.
Created attachment 206004 [details]
testcase from reporter's URL


12 years ago
Keywords: testcase
Caused by the call to advanceFocusIntoSubtree.
Component: General → XUL Widgets
Ever confirmed: true
OS: Windows XP → All
Product: Firefox → Toolkit
QA Contact: general → xul.widgets
Hardware: PC → All

Comment 3

12 years ago
Created attachment 206814 [details] [diff] [review]
make tabbox check that the focus doesn't leave it
Assignee: nobody → asqueella
Attachment #206814 - Flags: first-review?(neil.parkwaycc.co.uk)

Comment 4

12 years ago
Comment on attachment 206814 [details] [diff] [review]
make tabbox check that the focus doesn't leave it

We could really do with an "advanceFocusWithinSubtree" method...

>+            // Make sure that the focus doesn't move outside the tabbox
>+            var parent = this.parentNode;
>+            while (parent && parent.localName != "tabbox")
>+              parent = parent.parentNode;
Nit: I don't think we want to do the rest of the tests if no tabbox is found, compare with the selectedIndex setter.

>+            var el = document.commandDispatcher.focusedElement;
Nit: This could throw an exception in content, so you ought to try/catch it.
Attachment #206814 - Flags: first-review?(neil.parkwaycc.co.uk) → first-review+

Comment 5

12 years ago
Created attachment 208597 [details] [diff] [review]
update to comments

The original code seemed simpler to me...
Attachment #206814 - Attachment is obsolete: true
Attachment #208597 - Flags: first-review?(neil.parkwaycc.co.uk)

Comment 6

12 years ago
Comment on attachment 208597 [details] [diff] [review]
update to comments

Sorry for the delay.
Attachment #208597 - Flags: first-review?(neil) → first-review+


12 years ago
Whiteboard: [checkin needed]
Target Milestone: --- → mozilla1.9alpha1
Version: unspecified → Trunk
mozilla/toolkit/content/widgets/tabbox.xml; new revision: 1.32;
mozilla/xpfe/global/resources/content/bindings/tabbox.xml; new revision: 1.39;
Last Resolved: 12 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Target Milestone: mozilla1.9alpha1 → mozilla1.8.1
Version: Trunk → 1.8 Branch
Attachment #208597 - Flags: approval-branch-1.8.1?(neil)


12 years ago
Attachment #208597 - Flags: approval-branch-1.8.1?(neil) → approval-branch-1.8.1+
Keywords: fixed1.8.1
You need to log in before you can comment on or make changes to this bug.