Closed Bug 320429 Opened 19 years ago Closed 18 years ago

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

Categories

(Toolkit :: UI Widgets, defect)

1.8 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8.1

People

(Reporter: starwed, Assigned: asqueella)

References

()

Details

(Keywords: fixed1.8.1, testcase)

Attachments

(2 files, 1 obsolete file)

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.
Keywords: testcase
Caused by the call to advanceFocusIntoSubtree.
Status: UNCONFIRMED → NEW
Component: General → XUL Widgets
Ever confirmed: true
OS: Windows XP → All
Product: Firefox → Toolkit
QA Contact: general → xul.widgets
Hardware: PC → All
Assignee: nobody → asqueella
Status: NEW → ASSIGNED
Attachment #206814 - Flags: first-review?(neil.parkwaycc.co.uk)
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+
The original code seemed simpler to me...
Attachment #206814 - Attachment is obsolete: true
Attachment #208597 - Flags: first-review?(neil.parkwaycc.co.uk)
Comment on attachment 208597 [details] [diff] [review]
update to comments

Sorry for the delay.
Attachment #208597 - Flags: first-review?(neil) → first-review+
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;
Status: ASSIGNED → RESOLVED
Closed: 18 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)
Attachment #208597 - Flags: approval-branch-1.8.1?(neil) → approval-branch-1.8.1+
mozilla/toolkit/content/widgets/tabbox.xml 			1.28.2.3
mozilla/xpfe/global/resources/content/bindings/tabbox.xml 	1.35.8.4
Keywords: fixed1.8.1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: