fix: uui-file-dropzone does not follow the inferred interface for dropped files #478
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 typeFileEntry
, which is an older API. This was due to the fact that the partly supported Webkit methodwebkitGetAsEntry()
was being used for dropped files (DataTransferItem's).The remediation is to use the
getAsFile()
method instead and also to make sure, thatwebkitGetAsEntry()
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.