Bug 3582 - onDrop ignored in <textarea>
Summary: onDrop ignored in <textarea>
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 412
Hardware: Macintosh OS X 10.4
: P2 Normal
Assignee: Adele Peterson
Depends on:
Reported: 2005-06-16 19:36 PDT by Jakub Nesetril
Modified: 2010-01-11 21:46 PST (History)
4 users (show)

See Also:

Testcase - drop text onto the textarea (451 bytes, text/html)
2005-06-16 19:38 PDT, Jakub Nesetril
no flags Details
Working example (474 bytes, text/html)
2009-11-27 15:30 PST, Daniel Bates
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Nesetril 2005-06-16 19:36:39 PDT
By default, you can drag text (or even files) onto textarea, however, this action does not trigger the 
onDrop event.

Steps to reproduce:
* select arbitrary text
* drop onto the textarea

Expected results:
* logging the action via the scripted ondrop event

Assigned to Darin Adler for similarities to bug#3256
Comment 1 Jakub Nesetril 2005-06-16 19:38:42 PDT
Created attachment 2413 [details]
Testcase - drop text onto the textarea
Comment 2 mikepk 2007-04-02 13:54:28 PDT
I would add that it's not just onDrop, but any drag event (ondragover, ondragenter, ondragleave). Strangely only the border of the textarea (the 1 pixel line around the textarea) seems to fire these events but the body of the textarea does not.

Also positioning elements above a textarea (absolutely positioned) causes events not to fire on that element either (seems as if the textarea below the elements is intercepting and sinking the events). Dropping text on a div, absolutely positioned above a textarea causes the text to appear in the textarea (instead of being handled by the upper element).
Comment 3 Julie Parent 2009-05-06 00:10:14 PDT
drop also seems to never fire for contentEditable regions.
Comment 4 Daniel Bates 2009-11-27 15:27:37 PST
The test case (<https://bugs.webkit.org/attachment.cgi?id=2413>) is invalid, because it does not listen for the dragenter and dragover events as required by section 7.9.1 of the HTML 5 spec, <http://dev.w3.org/html5/spec/Overview.html#introduction-4>. In particular, the spec. states,  "to accept a drop, the drop target has to listen to at least three events: [dragenter, dragover, and drop]".

When the above prerequisite is satisfied, we do not ignore ondrop events to textareas. Moreover, dragenter, dragover, and drop events are all delivered to the textarea.

Actually, we fire the ondrop event so long as the textarea is listening for dragover events. We should probably file a separate bug to make dragenter also required.
Comment 5 Daniel Bates 2009-11-27 15:30:29 PST
Created attachment 43973 [details]
Working example

In this example, the textarea listens for dragenter, dragover, and drop events. When you successfully drop the text (in whole or in part) on the textarea, a JavaScript alert will be shown, "Caught drop."
Comment 6 Adele Peterson 2010-01-11 21:46:58 PST
Dan's analysis makes sense to me.