Open Bug 151827 Opened 22 years ago Updated 2 years ago

Incorrect behavior using onkeydown to capture of keycode is 9 (tab) and change form input focus.

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
Windows 2000
defect

Tracking

()

People

(Reporter: adent42, Unassigned)

References

()

Details

From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.0) Gecko/20020530 BuildID: 2002053012 When trying to capture TAB(9) with javascript onkeydown to redirect focus to another form input, mozilla will focus on the form input FOLLOWING the one specified. It looks like the javascript code is executed and THEN TABS's functionality is executed, changing the field focus twice. Reproducible: Always Steps to Reproduce: 1. Go to http://www.stupidstartups.com/tabproblem.html 2. select the first form text field. 3. press tab Actual Results: The input focus is set to the third form input (rightmost) rather than the second (middle) as expected. Expected Results: The input focus should be set to the second box. Example code: <html> <head><title></title> <script language="JavaScript"> function tabNext (nextfield, evt) { var keyCode = document.layers ? evt.which : document.all ? evt.keyCode : evt.keyCode; if ((keyCode == 13)||(keyCode == 9)) { nextfield.focus(); return false; } else { return true; } } </script> </head> <body> <form name=form> <input name=confirm1 onkeydown='return tabNext(this.form.confirm2,event);'> <input name=confirm2 onkeydown='return tabNext(this.form.confirm3,event);'> <input name=confirm3> </form> </body> </html>
Browser, not engine ---> Event Handling. Confirming bug with Mozilla trunk binary 2002061208 WinNT. There is some timing issue involved. When we step through the testcase in the Mozilla JS Debugger (Tools > Web Development > JavaScript Debugger), focus is successfully given to the second form input. But if we run the test without the debugger, focus ends up on the third form input.
Assignee: rogerl → joki
Component: JavaScript Engine → Event Handling
QA Contact: pschwartau → rakeshmishra
Status: UNCONFIRMED → NEW
Ever confirmed: true
QA Contact: rakeshmishra → trix
.
Assignee: joki → saari
QA Contact: trix → ian
Assignee: saari → nobody
QA Contact: ian → events
Summary: Incorrect behavior using onkeydown to capture of keycode is 9 (tab) and chang form input focus. → Incorrect behavior using onkeydown to capture of keycode is 9 (tab) and change form input focus.
Component: Event Handling → User events and focus handling

I am unable to reproduce this using the HTML code in the description.
(The linked URL no longer works.)

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.