Event.target is not set correctly in contentEditable

UNCONFIRMED
Unassigned

Status

()

P5
normal
UNCONFIRMED
4 years ago
7 months ago

People

(Reporter: brunoaiss, Unassigned)

Tracking

37 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
Created attachment 8585362 [details]
Test example for what I mean

When attaching events to the DOM inside a contentEditable, the events thrown (at least for keypress, keyup and keydown) don't have the correct value for the target attribute.

In the example, try typing anything anywhere and see the target value result of the event in the javascript logs.
The Element in the Event.target of the event callback is the Element where contentEditable is set to true (and, by chance, the same Element where the event was attached).

Instead, the element in the Event.target should be the actual innermost element where the event happened, which is where the event bubbling actually started.

Updated

4 years ago
Attachment #8585362 - Attachment mime type: text/plain → text/html

Comment 1

4 years ago
I see the same behavior in other browsers too, and given the contenteditable element is the
activeElement, key events should go there.

Why you think this behavior is incorrect?

Perhaps you want to use DOM0 UIEvent's rangeParent + rangeOffset properties?
(Reporter)

Comment 2

4 years ago
For example, I want to detect user clicks in a button that is inserted as part of the WYSIWYG such that when the editable button is clicked, it causes certain javascript to run.
Ofc, any javascript the user writes is useless when the data is sent to the server (it is ignored)
QA Whiteboard: [triaged]
Bulk priority change, per :mdaly
Priority: P3 → P5
You need to log in before you can comment on or make changes to this bug.