Closed Bug 147927 Opened 22 years ago Closed 21 years ago

javascript focus() only moves the cursor not the focus

Categories

(Core :: DOM: Core & HTML, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: allen.cook, Assigned: bryner)

References

Details

(Keywords: testcase, Whiteboard: [patch])

Attachments

(3 files)

using the JavaScript .focus() property moves my cursor but not the keyboard focus.
After the call my cursor is in the desired text box; but the focus remains in a
select list; that would have been the next form element.  The cursor remains in
the text box assigned by the JavaScript .focus() call: unitl the actual keyboard
focus hits another text box.  This does not happen in IE5.5sp2 or NetScape 4.73
Browser, not engine ---> DOM Level 0.

Allen, could you provide a reduced testcase or a URL to one?
We need to see exactly what's going wrong. Without that,
we'll have to close this bug. Also, please include the Mozilla
build ID in any bug report you file.

Note to attach a testcase, just go to the URL of this bug,
http://bugzilla.mozilla.org/show_bug.cgi?id=147927, and click 
on the "Create a New Attachment" link.


Compare:

bug 120995 
<input onblur="this.focus()"> doesn't work, the focus is not set

bug 109962 
Text input field doesn't get focus after HTMLInputElement.focus() 
(also on the onblur handler)

bug 53579  
calling this.blur()  in onfocus handler 
or      this.focus() in an onblur handler do not work 
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale
my current Mozilla build...
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc3) Gecko/20020523
Mozilla 1.0 Release Candidate 3
Attached file better test form
includes one element that actually works in IE or Netscape this time.
and one that works in Netscape.
I still have not been able to get this to work in Mozilla.
Confirming bug, 2002061008/linux

Another testcase here: http://myxomop.com/bugzilla/focustest.html
Blocks: focusblink
This worksforme on Linux... over to bryner, who may know what's up
Assignee: jst → bryner
I suspect the checkin for bug 92525 may have fixed this as well.  Can someone
re-test?
Bug is still present with Windows 2000 pro/ mozilla 1.1b 2002072104

However the bug does not exist with
Red Hat Linux 7.2 / mozilla 1.0 2002052918
Actually, the wrong bug number was cited in the checkin comment.  Bug 138191 is
what may have actually fixed this.  This was checked in on 7/24; can you please
test a build from 7/25 or newer?
It's still there used build 2002081218 in both Windows NT and Win 2000 Pro.
Both still have the bug.
*** Bug 135616 has been marked as a duplicate of this bug. ***
reporter (Allen): can you reproduce this bug with a recent build of mozilla (for
example, 1.2)? if so, please comment again with details. if not, please resolve
this bug as WORKSFORME. thanks.
build id: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2b) Gecko/20021016
OS Windows 2000 pro

Bug is still present. No change with the build listed above.
Reporter: Can you reproduce this bug with a recent build of Mozilla (for
example, 1.4 RC1)? If so, then please comment again with details. If not, then
please resolve this bug as WORKSFORME. Thanks.
using the second test with Mozilla trunk 2003072704 on win2k, this still happens.

confirming.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
*** Bug 217167 has been marked as a duplicate of this bug. ***
OS: Windows 2000 → All
Attached patch possible fixSplinter Review
I need to test this some more, I'm just putting the patch here so I don't lose
track of it.
Whiteboard: [patch]
Comment on attachment 130613 [details] [diff] [review]
possible fix

This is a pretty simple change, which is along the same lines as my patch from
bug 53579.  That patch caused us to not focus what we thought was the new
focused content if blurring the old content changed the focus.	This is really
just a case that I missed there - if the blur handler focused some other
content, we don't want to clear that out by calling SetFocusedContent(nsnull). 
Note that this causes us t only null out the focused content in the case where
we _don't_ do an early return below.
Attachment #130613 - Flags: superreview?(jst)
Attachment #130613 - Flags: review?(john)
Comment on attachment 130613 [details] [diff] [review]
possible fix

sr=jst
Attachment #130613 - Flags: superreview?(jst) → superreview+
Comment on attachment 130613 [details] [diff] [review]
possible fix

No response from John... blizzard, can you take a look?
Attachment #130613 - Flags: review?(john) → review?(blizzard)
Attachment #130613 - Flags: review?(blizzard) → review+
Comment on attachment 130613 [details] [diff] [review]
possible fix

Can I get this in for 1.6a?  I believe it's pretty safe; I've been running with
it in my tree for some time now.
Attachment #130613 - Flags: approval1.6a?
Comment on attachment 130613 [details] [diff] [review]
possible fix

a=sspitzer for 1.6a
Attachment #130613 - Flags: approval1.6a? → approval1.6a+
checked in.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
In case this is considered for the 1.4 branch sometime in the future:
it could cause a regression (bug 232368), see also bug 118685.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: