Closed Bug 120148 Opened 23 years ago Closed 21 years ago

Tabs don't remember which element [frame, textfield, etc] was focused when switching tabs

Categories

(SeaMonkey :: Tabbed Browser, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.6beta

People

(Reporter: jonasj, Assigned: niederstrasser)

References

(Blocks 1 open bug, )

Details

(Keywords: access)

Attachments

(2 files, 2 obsolete files)

* Go to a page that uses frames * Switch to another tab * Switch back * Press the up or down arrow - the page doesn't scroll.
Reassigning to new component owner.
Assignee: hyatt → jaggernaut
-> future, helpwanted
Keywords: helpwanted
Target Milestone: --- → Future
If focus is in a textfield, and I switch to another tab and then switch back, the textfield doesn't get focused again. That's probably the same bug as this - tabbrowser needs to remember which element was focused the last time the tab was active. That element could either be an HTML element (like a textfield) or a page inside the frameset. Adding access keyword and updating summary.
Keywords: access
Summary: Frameset pages loses focus when switching tabs → Tabs doesnwhich element was focused
If focus is in a textfield, and I switch to another tab and then switch back, the textfield doesn't get focused again. That's probably the same bug as this - tabbrowser needs to remember which element was focused the last time the tab was active. That element could either be an HTML element (like a textfield) or a page inside the frameset. Adding access keyword and updating summary.
Summary: Tabs doesnwhich element was focused → Tabs don't remember which element was focused when switching tabs
Oops... sorry about that.
We should be able to do this by storing the focused element/window and resetting those when switching back to the tab.
*** Bug 124089 has been marked as a duplicate of this bug. ***
aaronl, should this go to you since you're working on similar issues?
Keywords: nsbeta1
No, this should go to bryner or jaggernaut. I'll pick up some of their focus/navigation bugs if I get the chance, but now isn't a good time.
nsbeta1+ per ADT triage team, ->1.0
Keywords: nsbeta1nsbeta1+
Target Milestone: Future → mozilla1.0
ended up kinda testing this issue during the course of using a 2/20 test build for bug 66597 and bug 120023. a. caret browsing on, two tabs: switching btwn the tabs seems to preserve focus in that the caret remains visible. if i click w/the mouse to switch tabs, the focus ring around a focusable item persists. but if i switch using ctrl+pageUp/pageDown, the focus ring disappears [but the caret does not]. b. caret browsing off, two tabs: if i click w/the mouse to switch tabs, the focus ring around a focusable item also persists. but if ctrl+pageUp/pageDown is used, the focus ring is lost. however, in both cases --as with case (a)-- focus is where i last left it, since tabbing/shift+tabbing proceeds as exoected anyhow. c. hrm, cannot seem to reliably repro the weird case [bug 66597 comment 45 part] where the previously focused item still has the focus ring [when it's not supposed to], or other erratic oddments like seeing focus rings on multiple items... sigh. will post recipe if i can get either of these to occur reliably...
Blocks: 128632
nsbeta1- per ADT triage. We believe that users are able to recover by tabbing to the ext field. Pls renominate, if this is not true.
Keywords: nsbeta1+nsbeta1-
It seems to me like users could be as lost as the focus. For instance, on the current page, a it took 126 tabs to get back to the text area I was in before switching tabs, though if I still used the product rather than switching to IE, I might eventually learn to do tab + shift tab on such occasions. Aaron?
Target Milestone: mozilla1.0 → mozilla1.0.1
Yes, there's also a bug somewhere that the focus is not remembered when you go back or forward in history. However, I wouldn't call this nsbeta1+. It's a usability irrititation, which should eventually be fixed, perhaps not now. If this is a huge concern to a user, they don't have to use tabbed browsing.
Target Milestone: mozilla1.0.1 → mozilla1.1
*** Bug 140390 has been marked as a duplicate of this bug. ***
Found more info on this bug: Steps I followed: 1. Open mozilla 2. go to a website 3. CTRL-T -> go to another website 4. Click on the 1st tab (did not click inside the client area of 1st tab) 5. (Forgot about this bug and) started typing. 6. Pressed Enter: Thats when I noticed that the Enter went to the 2nd tab!! I guess the Enter should have gone to the 1st tab. Looks like the tab in whihc one clicks the mouse retains focus unless you click "inside" the contents of the tab in which you want the focus to go. I hope I have not made this very confusing. Please let me know if I can provide more details. Browser details: Build ID from title Bar: 2002041203 Help->About Mozilla 0.9.9+ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:0.9.9+) Gecko/20020412 Thanks for creating such a fine product. Ajay Gautam :)
*** Bug 150240 has been marked as a duplicate of this bug. ***
So... Is there an HTML equivalent of the command dispatcher? It seems like the simple solution to this situation is to simply store the element that is focused when switching away from a tab and to make sure that it gets focused when we switch back (have to watch out for unwanted onfocus events here, though). The problem is getting the "currently focused element" out of an HTML document....
Do you want to get the currently focused element in Javascript or C++? I can't find a js way to do this: nsCOMPtr<nsIScriptGlobalObject> ourGlobal; document->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); nsCOMPtr<nsPIDOMWindow> ourWindow(do_QueryInterface(ourGlobal)); if (ourWindow) ourWindow->GetRootFocusController(getter_AddRefs(focusController));
*** Bug 152636 has been marked as a duplicate of this bug. ***
*** Bug 158745 has been marked as a duplicate of this bug. ***
renominating for buffy.
Keywords: nsbeta1-nsbeta1
Nav triage team: nsbeta1+/adt3
Keywords: nsbeta1nsbeta1+
Whiteboard: [adt3]
Summary: Tabs don't remember which element was focused when switching tabs → Tabs [frames, textfields] don't remember which element was focused when switching tabs
Yeah, we never implemented focus memory for tabs the same way as it works for windows. I'd actually be quite hesitant to do that (create a FocusController per tab) because it seems very risky. I think what bz suggests is the way to go. We need to make sure to restore the focused DOMWindow as well as the focused element. Would installing a capturing focus listener on the <browser> allow you to track focus changes?
Blocks: focusnav
QA Contact: sairuh → pmac
See also bug 124750, "other tab steals focus with javascript textbox.focus()".
*** Bug 139766 has been marked as a duplicate of this bug. ***
Is this a duplicate of bug 112081 ? Or vice-versa as there are more comments in this bug here and the summary is not as specific...
Actually, that bug is a purely visual issue. This bug is about the focus not being persisted. Fixing this may fix the visual problem, of course.
Blocks: 112081
Nav triage team: nsbeta1-
Keywords: nsbeta1+nsbeta1-
Whiteboard: [adt3]
Summary: Tabs [frames, textfields] don't remember which element was focused when switching tabs → Tabs don't remember which element [frame, textfield, etc] was focused when switching tabs
QA Contact: pmac → sairuh
Target Milestone, should it be changed to future?? We're already way past the Mozilla 1.1 alpha milestone...
*** Bug 202937 has been marked as a duplicate of this bug. ***
Keywords: nsbeta1-nsbeta1
Target Milestone: mozilla1.1alpha → mozilla1.4beta
So if the element isn't focusable, it won't have a focus method, in which case I can fall back to setting focus on the focusedWindow, instead of always setting focus on it. Also use lookupMethod to get at the original focus method instead of a user defined one.
Attachment #121638 - Attachment is obsolete: true
Comment on attachment 121644 [details] [diff] [review] Remember where focus is when switching tabs (without exceptions) Please add a comment about where setfocus is false, and why you want to treat that differently. It confused me for a minute until I realized what was going on. Looks good otherwise. r=caillon. >+ if (this.getAttribute("setfocus") != "false") { >+ next.focus(); >+ document.commandDispatcher.advanceFocusIntoSubtree(next); >+ }
Attachment #121644 - Flags: review+
Comment on attachment 121644 [details] [diff] [review] Remember where focus is when switching tabs (without exceptions) Please add a comment about where setfocus is set, and why you want to treat that differently. It confused me for a minute until I realized what was going on. Looks good otherwise. r=caillon. >+ if (this.getAttribute("setfocus") != "false") { >+ next.focus(); >+ document.commandDispatcher.advanceFocusIntoSubtree(next); >+ }
// set to false by users of <tabs> (e.g. tabbrowser) to indicate // they don't want us to set focus to the selected panel Comment added.
Attachment #121644 - Flags: superreview?(bryner)
Are we calling window.focus there? Will that not raise the Mozilla window when called? Could you please test that switching tabs while the Mozilla window is not on top does _not_ raise it?
Boris, I don't think you should be concerned with that as you cannot switch tabs if the Mozilla window is not on top.
bz: like Roman R. said, it's kinda hard to switch tabs while the window is not on top, since there's no programmatic way of doing it. Maybe if you try really hard you can switch to another tab, then switch the window to the background before the focus() call gets processed, but it's a bit of an edge case and I'm not changing anything about that aspect of the code (though I'd be happy to address that in another bug if deemed necessary).
Actually, on linux, it is possible to do that if you have keyboard focus on whatever the mouse is over and mozilla is a background window. Ctrl+PgUp/PgDown.
Um.. That wasn't a theotical question, guys. If you're not using a windowmanager that enforces raise-on-focus (most Linux windowmanagers) then it's trivial to switch tabs without the Mozilla window being on top. And Mozilla raising itself when you did that would be totally unacceptable.
I don't think we raise on linux when we focus a window. Easy enough to test though with any recent nightly, we call focus with and without this patch, the only difference is the element focused.
We certainly raise on Linux if window.focus() is called. Focusing things other than the window does _not_ raise. It may also not raise if called from chrome. The point is, it would be good if someone were to test that before checking this in....
Comment on attachment 121644 [details] [diff] [review] Remember where focus is when switching tabs (without exceptions) I don't think this will cause us to raise the window when you switch tabs in any case where we don't currently. Looks fine to me. sr=bryner.
Attachment #121644 - Flags: superreview?(bryner) → superreview+
Attachment #121644 - Flags: approval1.4b?
I'll test that before checking in. If the user can somehow make the focusedWindow be the XUL window with focusedElement being null, then that's one case where we could end up (effectively) calling window.focus();
Comment on attachment 121644 [details] [diff] [review] Remember where focus is when switching tabs (without exceptions) a=asa (on behalf of driver) for checkin to 1.4b
Attachment #121644 - Flags: approval1.4b? → approval1.4b+
Comment on attachment 121644 [details] [diff] [review] Remember where focus is when switching tabs (without exceptions) I can get into a state where if you load a (big/slow) page in a tab, then switch to another tab and put focus in the URL bar, then switch back to the tab that's still loading, focus will stay in the URL bar instead of going to content. I think resetting the cached focusedWindow and focusedElement from onLocationChange will "fix" this.
adt: nsbeta1-
Keywords: nsbeta1nsbeta1-
[Mozilla/5.0 (Windows; U; Win95; en-US; rv:1.4) Gecko/20030624] (v1.4rc3) Bug still there. Any news since v1.4b checkin approval in comment 46 ? (2 months ago)
*** Bug 211848 has been marked as a duplicate of this bug. ***
This bug still appears to be there using v1.4...
*** Bug 215370 has been marked as a duplicate of this bug. ***
*** Bug 215756 has been marked as a duplicate of this bug. ***
How about driving this in for 1.6a, please? Thanks!
Flags: blocking1.6a?
Attachment 121644 [details] [diff] no longer patches cleanly against the trunk. I've fixed the patch to match the current source and it does _not_ fix the bug on Firebird (on Mac OS X built today): tabs still forget their focus. I'm attaching the corrected patch if someone can try it on Seamonkey.
Updated patch to patch cleanly.
Updated patch to patch cleanly.
Comment on attachment 132484 [details] [diff] [review] Remember where focus is when switching tabs (updated) Sorry about the double patch.
Attachment #132484 - Attachment is obsolete: true
Comment on attachment 121644 [details] [diff] [review] Remember where focus is when switching tabs (without exceptions) Hm, when you say you tried this patch, did you mean you made equivalent changes to equivalent files in firebird? Of course this patch will not work in Firebird without any munging because it is a Seamonkey only patch....
Comment on attachment 132485 [details] [diff] [review] Remember where focus is when switching tabs (updated) Obsoleting redundant patch (identical to previous, AFAICS).
Attachment #132485 - Attachment is obsolete: true
Comment on attachment 132485 [details] [diff] [review] Remember where focus is when switching tabs (updated) Oops... I'm not alone here. Sorry.
Attachment #132485 - Attachment is obsolete: false
Comment on attachment 132485 [details] [diff] [review] Remember where focus is when switching tabs (updated) Christopher Aillon: > Hm, when you say you tried this patch, did you mean you made equivalent > changes to equivalent files in firebird? Of course this patch will not > work in Firebird without any munging because it is a Seamonkey only patch.... Sorry. I was partly confused. Here's a (hopefully) clearer description of what I've done: 1) Attachment 121644 [details] [diff] no longer patches cleanly to the trunk because of other changes to the patched files since the patch was written. 2) Because the patch had bit rotted, I fixed the patch to patch cleanly without errors (this is attachment 132485 [details] [diff] [review]). 3) I tried the fix against Firebird, but it didn't work. As you've now pointed out, the patch only patches seamonkey code. I'm still working on figuring out what will affect which project. Lesson learned. 4) I have now built Seamonkey with my patch and it does fix the loss of focus when tabs are switched. The patch I've submitted does the same exact modifications as the original patch (attachment 121644 [details] [diff] [review]). It just takes into account changes to the affected files from the last 5 months. Because the patch is the same otherwise, I'm requesting review so that we can move to finally check this in.
Attachment #132485 - Flags: superreview?(bryner)
Attachment #132485 - Flags: review?(caillon)
Can you answer the question that was raised in comment 37? See ensuing discussion up to comment 45.
From comment 63 (caillon): > Can you answer the question that was raised in comment 37? From comment 37 (bz): > Could you please test that switching tabs while the Mozilla window is > not on top does _not_ raise it? The bottom Mozilla window is _not_ raised when its tabs are switched (Linux with WindowMaker) by either clicking the tab or ctrl-pgup/pgdn. Textboxes retain their carets and respond to typing when that tab is made active.
Great! If the same is true when the thing that has focus is the main page and not a textbox in it, then my worries are completely dispelled.
bz: If the page has focus (ie keyboard scrolling works) and I switch to another tab where the focus is on a text area, switching back to the first tab keeps focus on the document.
Right. What I meant was that if that does not cause the window to raise, then things are good.
Ah. The active window does not rise when switching to another tab, regardless of where focus is on that tab (document, text box, URL bar).
Attachment #132485 - Flags: superreview?(bryner) → superreview+
checked in
Assignee: jag → tryandguessit
This is fixed now after the checkin. For the Firebird resolution of this, see bug 224416.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
ooi what firebird and mozilla releases will be bundled with this fix?
mozilla 1.6beta (or current nightyl nbuilds). firebird will have to wait until bug 224416 is fixed
Keywords: helpwanted
Target Milestone: mozilla1.4beta → mozilla1.6beta
Product: Core → SeaMonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: