w3c / uievents

UI Events
https://w3c.github.io/uievents/
Other
144 stars 51 forks source link

Define events for drag-and-drop operations (textInput etc) #367

Open zcorpan opened 5 months ago

zcorpan commented 5 months ago

See https://github.com/w3c/uievents/pull/362#discussion_r1458219635

https://html.spec.whatwg.org/#drag-and-drop-processing-model defines the drag and drop model and some events, and refers to Pointer Events spec for some events.

When performing a drag and drop operation in an editing host (or dropping in an editing host), browsers fire textInput, beforeinput, mutation events, input -- which isn't currently defined as far as I can tell.

Interestingly, the event order in Chromium and WebKit is textInput and then beforeinput, which maybe should be the other way around for consistency with input from typing.

Demo: https://software.hixie.ch/utilities/js/live-dom-viewer/saved/11841

I think this should integrate somehow with this part of HTML:

If the current target element is a text control (e.g., textarea, or an input element whose type attribute is in the Text state) or an editing host or editable element, and the drag data store item list has an item with the drag data item type string "text/plain" and the drag data item kind text

Insert the actual data of the first item in the drag data store item list to have a drag data item type string of "text/plain" and a drag data item kind that is text into the text control or editing host or editable element in a manner consistent with platform-specific conventions (e.g. inserting it at the current mouse cursor position, or inserting it at the end of the field).

cc @masayuki-nakano

zcorpan commented 4 months ago

Interestingly, the event order in Chromium and WebKit is textInput and then beforeinput, which maybe should be the other way around for consistency with input from typing.

Gecko's behavior with @masayuki-nakano 's patch for https://bugzilla.mozilla.org/show_bug.cgi?id=903746 is beforeinput event then textInput. I've created a PR with a tentative test for this event order: https://github.com/web-platform-tests/wpt/pull/44744

cc @sideshowbarker