[DropZone] Fix error on dragenter for glb/gltf files #12135
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.
WHY are these changes introduced?
Fixes #6644
The goal is to have correct filtering in the OS file picker and also correct dropzone overlay messaging. This is currently not possible for glb/gltf files because:
.glb
(the mime type does not work).glb
file from the OS file picker into the dropzone, the overlay shows an error because the dragenter event gets an empty mime type and does not have access to the filename, so the validation against theaccept
string fails. Note that even though an error is shown, if you drop the file it is acceptedWHAT is this pull request doing?
This PR makes it so that if the
accept
prop contains any file extensions (ie. starts with a.
), then on dragenter events, file validation agains theaccept
string is skipped (the customValidator will still run). The file will be validated against theaccept
string once it is dropped, because at that point the file name is known.BEFORE
With
accept
=.glb
.glb
.glb
file from the OS file picker onto the dropzone component shows an error:AFTER
With the same
accept
prop:If the
accept
prop contains only MIME types (and no file extensions), the behaviour of dragging a file over the dropzone is the exact same as before this change.How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Paste the following in the Playground:
.glb
extension should be selectable..glb
file. It should show up in theAccepted files
list.glb
file from the OS file picker into the dropzone. There should be no error overlayAccepted files
list.glb
from the OS file picker into the dropzone. There should be no error overlayRejected files
list🎩 checklist
README.md
with documentation changes