Closed Bug 333475 Opened 20 years ago Closed 19 years ago

onkeydown preventDefault doesn't cancel keypress on Mac

Categories

(Core Graveyard :: Widget: Mac, defect)

1.8 Branch
PowerPC
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.8.1

People

(Reporter: mark, Assigned: mark)

Details

(Keywords: testcase)

Attachments

(1 file)

On the Mac, an onkeydown event handler that calls event.preventDefault() does not suppress the keystroke from being handled in some situations. In the testcase, a <div> with style display:none is shown in response to a keydown event, and an <input> contained therein is focused. The event then has preventDefault called on it. On Linux and Windows, the key pressed does not register any input in the now-focused <input> field. On Mac, the key pressed causes a keypress to appear in the text field, even though the keydown handler called preventDefault. I think we may have an open bug on this, but I can't find it.
Attached file Testcase
Open the testcase and press the 'z' key to unhide a <div> and focus an <input type="text"> that it contains. Expected results: the 'z' is not added to the text field because preventDefault was called. Observed results (on Mac): the 'z' is added to the text field. The workaround clears the text field on a zero-duration timer after displaying the <div>.
This problem was mentioned in bug 333475.
Of course it was! Did you have another bug in mind?
Oops. This problem was mentioned in bug 332561.
Assignee: events → mark
I fixed this in bug 337199 after I rewrote the key event handlers.
Status: NEW → RESOLVED
Closed: 19 years ago
Component: DOM: Events → Widget: Mac
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.8.1
Product: Core → Core Graveyard
Version: Trunk → 1.8 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: