Enhance FileChooser
to allow better app-level handling of file rejections
#3350
Labels
FileChooser
to allow better app-level handling of file rejections
#3350
The underlying react-dropzone that powers this component can be configured to reject files based on type and size, both of which are exposed as options in our API within
FileChooserProps
.However the handling around rejected files is very limited. The model will set an observable
lastRejectedCount
property when a rejection occurs, but this does not appear to be cleared or otherwise incremented. This means that if you attempt to add a single file and its rejected, you will see the count go to 1, but if you try another (single) file the count will remain at 1 and no observable change occurs (this I would say is a straight-up bug, or at least useless enough to be effectively broken).There is some code in the Hoist component that reads this value and looks like it should show a message, but I'm not seeing this work at all with our in-app usage.
The underlying API provides much more info on rejections in the form of a
FileRejectionEvent
with nested errors including messages that (presumably) help to explain what happened. If that were properly observable, or if the app could directly register a custom handler, an app could decide how it wanted to relay info to a user about why a file failed to "take" when dragged over the chooser or selected from the OS file browser. Right now it's just this silent failure, with no apparent workaround.The text was updated successfully, but these errors were encountered: