Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filemetadata available on dragstart #1610

Merged
merged 9 commits into from
Nov 22, 2019
Merged

fix: filemetadata available on dragstart #1610

merged 9 commits into from
Nov 22, 2019

Conversation

LeopoldLerch
Copy link
Contributor

Hi
This should fix the issue #584 .

I changed it so that when a file is dragged into the browser, it will create the nativesource together with the file informations. Before it simply created placeholders telling that browser wouldn´t allow it. That was only partially true. The browser allows to acces the file´s metadata like name, size, ... . However, it allows not to access its (binary) data. The binary data is available after the ondrop-event. Therefore on the ondrop event the nativedragsoure will be updated again with new DataTransfer-object.

However, this happens only on DragEnter into the browser and also only for the File-Nativetype. All the other ones stay the same. I was not really able to test them out correctly and the security that prevents from accessing the file´s binary data might effect here more, as the Link and escpecially the text don´t have any metadata at all.

I needed this for a rebuild of the "DropZone" with react-dnd. And the only issue was, that I was not able to react on the file´s metainfo (eg. filetype) prior to droping it (eg. marking the dropzone "green" when it is ok).

Pls have a look at it.

Regards
Leo

@darthtrevino darthtrevino self-assigned this Nov 22, 2019
@darthtrevino darthtrevino merged commit 1b5c2a3 into react-dnd:master Nov 22, 2019
@LeopoldLerch
Copy link
Contributor Author

Do you have an idea when this will be available via npm?

@darthtrevino
Copy link
Member

Hopefully this weekend, I have some things to get done at home today to prepare for the Holiday next week. I'll try to cut a release tonight

darthtrevino pushed a commit that referenced this pull request Feb 3, 2022
* fix: filemetadata available on dragstart

* refactor: rename mutateItemByReadingDataTransfer to loadDataTransfer

This commit also streamlines the condition we use to pass the dataTransfer object to the NativeDragSource.

* refactor: streamline datatransfer passing

* docs: improve native-files typings

* fix: update loadDataTransfer to accept null

* fix: linting issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants