Focus jumps two controls when handling tab onkeydown and showing an alert("") (or indeed pausing the thread by other means).

NEW
Unassigned

Status

()

Core
Event Handling
--
major
8 years ago
2 years ago

People

(Reporter: Ben, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.64 Safari/532.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)

I have a onkeydown event handler setup on a text input.
When the tab key is pressed I show an alert() box.
After clicking OK, focus has been moved 2 controls instead of one.

It seems this also happens with synchronous XHR's and anything else that pauses the current thread.

Reproducible: Always

Steps to Reproduce:
1. I have a onkeydown event handler setup on a text input.
2. When the tab key is pressed I show an alert() box.
3. After clicking OK, focus has been moved 2 controls instead of one.
Actual Results:  
After clicking OK, focus has been moved 2 controls instead of one.

Expected Results:  
Focus moved to the next control (not the next next control!).

A basic example:

<html>
    <head>
    </head>
    <body>
        <input onkeydown="oioi(event)" type="text" />
        <input type="text" />
        <input type="text" />
        <script>
            function oioi(e) {
                if (e.keyCode == 9) {
                    alert("hello");
                }
            }
        </script>
    </body>
</html>
Confirmed with Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.3a1pre) Gecko/20100118 Minefield/3.7a1pre

Firefox 1.0 and also Google Chrome and Opera do it as intended.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Duplicate of this bug: 1074140

Comment 3

2 years ago
I have added my vote to this as we have customers desiring to have this bug addressed.  Our customers are encountering the issue through the use case on the bug 1074140 which has been closed as a duplicate of this one.
You need to log in before you can comment on or make changes to this bug.