react-dnd / react-dnd

Drag and Drop for React

Home Page:http://react-dnd.github.io/react-dnd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get numbers of files during the dragging?

andrii-olefir-airslate opened this issue · comments

Describe the bug
I want to know how much files I dragging and show it on title
dragging files from os try to listen monitor.getItem() but always get
{ "files": [], "items": {}, "dataTransfer" }

how can I get this data before drop?
Reproduction

Live Reproduction

Steps to reproduce the behavior:

  1. dragging files from os
  2. drag enter to box and check the console

Screenshots

Снимок экрана 2023-08-29 в 13 55 43
Снимок экрана 2023-08-29 в 13 55 55

Desktop (please complete the following information):

  • OS: macOS 12.0.1
  • Browser chrome 116
  • Version 16.0.1

Answer:
Note: The files property of DataTransfer objects can only be accessed from within the drop event. For all other events, the files property will be empty — because its underlying data store will be in a [protected mode]

https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/files