File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed
Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -194,29 +194,44 @@ class DropManager extends Container {
194194 this . emit ( 'deactivate' ) ;
195195 }
196196
197- _onDragEnter ( evt ) {
197+ /**
198+ * Returns true if the drag event contains valid drop data.
199+ * Text selection drags have types like 'text/plain' but not 'Files'.
200+ *
201+ * @param evt - The drag event to validate.
202+ * @returns True if the drag contains valid data for the current dropType.
203+ */
204+ _isValidDrag ( evt : DragEvent ) {
205+ if ( this . _dropType === 'files' ) {
206+ const types = evt . dataTransfer ?. types ;
207+ return types && Array . from ( types ) . includes ( 'Files' ) ;
208+ }
209+ return true ;
210+ }
211+
212+ _onDragEnter ( evt : DragEvent ) {
198213 if ( ! this . enabled ) {
199214 return ;
200215 }
201216
202217 evt . preventDefault ( ) ;
203218
204- if ( this . readOnly ) {
219+ if ( this . readOnly || ! this . _isValidDrag ( evt ) ) {
205220 return ;
206221 }
207222
208223 this . _dragEventCounter ++ ;
209224 this . active = true ;
210225 }
211226
212- _onDragOver ( evt ) {
227+ _onDragOver ( evt : DragEvent ) {
213228 if ( ! this . enabled ) {
214229 return ;
215230 }
216231
217232 evt . preventDefault ( ) ;
218233
219- if ( this . readOnly ) {
234+ if ( this . readOnly || ! this . _isValidDrag ( evt ) ) {
220235 return ;
221236 }
222237
@@ -225,7 +240,7 @@ class DropManager extends Container {
225240 this . active = true ;
226241 }
227242
228- _onDragLeave ( evt ) {
243+ _onDragLeave ( evt : DragEvent ) {
229244 if ( ! this . enabled ) {
230245 return ;
231246 }
@@ -244,7 +259,7 @@ class DropManager extends Container {
244259 }
245260 }
246261
247- _onMouseUp ( evt ) {
262+ _onMouseUp ( evt : MouseEvent ) {
248263 if ( ! this . enabled ) {
249264 return ;
250265 }
@@ -255,7 +270,7 @@ class DropManager extends Container {
255270 this . active = false ;
256271 }
257272
258- _onDrop ( evt ) {
273+ _onDrop ( evt : DragEvent ) {
259274 if ( ! this . enabled ) {
260275 return ;
261276 }
You can’t perform that action at this time.
0 commit comments