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

NEW
Unassigned

Status

()

16 years ago
2 years ago

People

(Reporter: adent42, Unassigned)

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

16 years ago
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>

Comment 1

16 years ago
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

Updated

16 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true

Updated

16 years ago
QA Contact: rakeshmishra → trix

Comment 2

15 years ago
.
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.
You need to log in before you can comment on or make changes to this bug.