Closed Bug 799413 Opened 12 years ago Closed 8 years ago

social sidebar has focus at startup

Categories

(Firefox Graveyard :: SocialAPI, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: markh, Unassigned)

References

(Depends on 1 open bug)

Details

After starting FF when the sidebar has been previously enabled, the sidebar is focused, but the content window should have default focus.
It appears the problem is simply that the sidebar content is calling element.focus().  I doubt this is what we want to allow happening - in that case the element should be focussed *within* the sidebar, but shouldn't change which window actually gets focus.  Olli, do you have any thoughts?
Hmm, I would expect the code here to prevent that:
http://hg.mozilla.org/mozilla-central/annotate/90857937b601/dom/base/nsFocusManager.cpp#l1209

Since it prevents focus() in content from stealing focus from chrome (or from elements in other documents).
(In reply to :Gavin Sharp (use gavin@gavinsharp.com for email) from comment #2)
> Hmm, I would expect the code here to prevent that:
> http://hg.mozilla.org/mozilla-central/annotate/90857937b601/dom/base/
> nsFocusManager.cpp#l1209

And it does in the normal case :)  The focus stuff is hard to debug, so I'm a little vague about what is going on.  As content loads, it appears as though it doesn't yet have focus (the tabbrowser or app window does maybe?).  Then when content attempts to focus itself, it does get focus - at which point focus can't be stolen by other content.  It is that first grabbing of focus that we are hitting here.

Eg, if the content area contains the trivial HTML:

---
<script>
    window.addEventListener("load", function() {document.getElementById("theinput").focus()});
</script>
<input id="theinput">
---

The problem can't be reproduced - we can see the caret flashing in the input field.  When the sidebar loads and attempts to grab focus it fails (as expected).

If you comment out the load handler and try again, then the sidebar's attempt to get focus succeeds.  IOW, it appears neither the content window nor the sidebar initially has focus, so the first one to attempt to grab it wins.
Ah, tricky. Not sure how we can really work around that... short of disabling the sidebar from being able to "steal" focus (via .focus()) entirely, perhaps?
This will be hitting bug 604289 - but keeping this open to make sure it doesn't fall off the social radar.
Depends on: 604289
deprecation in fx51
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
Product: Firefox → Firefox Graveyard
You need to log in before you can comment on or make changes to this bug.