Skip to content

fix: uui-file-dropzone does not follow the inferred interface for dropped files #478

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

Merged
merged 10 commits into from
May 12, 2023

Conversation

iOvergaard
Copy link
Contributor

@iOvergaard iOvergaard commented May 11, 2023

Description

The event UUIFileDropzoneEvent stipulates that the "detail" object is of type File[]. However, when debugging at runtime you could see that the files were of type FileEntry, which is an older API. This was due to the fact that the partly supported Webkit method webkitGetAsEntry() was being used for dropped files (DataTransferItem's).

The remediation is to use the getAsFile() method instead and also to make sure, that webkitGetAsEntry() which is still useful for directories is being hidden away behind a guard statement.

In order to actually use the File interface instead, we also have to avoid pushing directory entries themselves to the event detail object but instead, only scan them and let their own entries enter the queue to be parsed (if supported in the browser).

Lastly, this PR aims to update the code a bit to avoid repeating the business logic to check for acceptance of files.

@iOvergaard iOvergaard enabled auto-merge (rebase) May 11, 2023 12:34
@iOvergaard iOvergaard added the bug Something isn't working label May 11, 2023
@iOvergaard iOvergaard requested a review from nielslyngsoe May 11, 2023 12:43
@iOvergaard iOvergaard changed the title fix: uui-file-dropzone do not use the correct interface for dropped files fix: uui-file-dropzone does not follow the inferred interface for dropped files May 12, 2023
Copy link
Member

@nielslyngsoe nielslyngsoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good and works :-)

I've added the default slot which must have been gone for some time. So now the browse story works again.

@iOvergaard iOvergaard merged commit ee5ff80 into v1/contrib May 12, 2023
@iOvergaard iOvergaard deleted the v1/bugfix/file-dropzone-entries branch May 12, 2023 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants