Closed Bug 374786 Opened 18 years ago Closed 14 years ago

Keyboard focus lost when hiding the currently focused input control from a custom onkeydown handler (unable to scroll the page after that)

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 570835
Tracking Status
status2.0 --- ?

People

(Reporter: legolas558, Unassigned)

References

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2 I spent 3 hours but finally I could find why Firefox' default keyboard handler did not handle the keyboard events. See the steps. Reproducible: Always Steps to Reproduce: 1. attach a hook function to document.onkeydown 2. before exiting the hook function put the style.display property of the currently focused input element to "none" Actual Results: if the input element is not set visible before exiting the hook funciton, the keyboard events will never be processed by the default keyboard, so the up/down scrolling keys for example do not work Expected Results: if I set the focus to another visible input element before exiting the hook function the bug does not happen and keys are correctly processed (up/down & co.) I think that the currently focused item internal variable get somewhat messed up when setting the item as non-visible; this bug does not happen with the evil IE
1. Can you try the latest trunk build to see if this is still a problem? 2. If it is, can you attach a minimal testcase to this bug to show such behaviour?
Testcase added - you were too fast! Unfortunately I cannot test on the trunk due to time constraints...please test it yourself (using the testcase) if you can, thank you. If the bug is still present, yuo won't be able to use scrollbars to scroll up/down
Sorry, I will better explain the previous final note: if the bug is still present on the trunk version, after having pressed escape on the textarea the scrollbars will not work pressing up/down as expected
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a3pre) Gecko/20070321 Minefield/3.0a3pre ID:2007032103 [cairo] I see this too 1. Load testcase 2. Click in area 'Focus me and press escape' 3. Press Escape 4. Hit return to dismiss the "You pressed escape!" dialog 5. Try and scroll page with arrow up/arrow dn/pgup/pgdn keys, and nothing happens Works in Opera 9. (In IE6 pressing escape doesn't prompt the dialog)
Keywords: testcase
Version: unspecified → Trunk
To make it work in IE6: (from line 7 to line 13) ------------------------ function kbd_hook(orig_e) { if (!orig_e) e = window.event; else e = orig_e; if (e.keyCode==27) { alert("You pressed Escape!"); go_external(); } return orig_e; } ------------------------ I cannot test it but I think it will work
Another workaround for the bug: take any element - not necessarily the one which is focused - and execute .blur() on it. The bug will not happen. You can add this in the testcase after line 22 (that with saver.focus()), so also saver.blur() will prevent the bug from happening. It must really be something related to the currently focused item variable(s). I have only recently reduced the bug to a testcase (I was not sure if it was a javascript problem of mine or else) but I can tell that it was present also in older versions (1.5 and maybe older)
This happens in other browsers too and other other platforms. -> Core::General for further triage.
OS: Windows XP → All
Product: Firefox → Core
QA Contact: general → general
Hardware: PC → All
Summary: (javascript) Default keyboard handler trashed when using a custom onkeydown handler and disabling the currently focused input control → (javascript) Default keyboard handler trashed when using a custom onkeydown handler and hiding the currently focused input control
Has this ever been fixed? Why is it unconfirmed? I have provided several testcases
Perhaps Neil is interested in this? FWIW, nsIFocusManager::focusedElement is still the HTMLTextAreaElement after it is hidden.
Blocks: 255317
Status: UNCONFIRMED → NEW
status2.0: --- → ?
Component: General → Keyboard: Navigation
Ever confirmed: true
QA Contact: general → keyboard.navigation
Summary: (javascript) Default keyboard handler trashed when using a custom onkeydown handler and hiding the currently focused input control → Keyboard focus lost when hiding the currently focused input control from a custom onkeydown handler (unable to scroll the page after that)
This bug is particularly evident when using Facebook, and looks like they are not aware of the workaround because focus is quickly lost after little time and you can no more use up/down keys.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
Component: Keyboard: Navigation → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: