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

FileChooser should provide full control over targetText/rejectText #3527

Open
amcclain opened this issue Nov 15, 2023 · 2 comments · May be fixed by #3538
Open

FileChooser should provide full control over targetText/rejectText #3527

amcclain opened this issue Nov 15, 2023 · 2 comments · May be fixed by #3538

Comments

@amcclain
Copy link
Member

The FileChooser component accepts a targetText prop, but always shows its own text when actively hovering over the target. It does not provide any control over the text displayed when a drop is rejected.

targetTxt = isDragActive

We have a usage in a client app where we are showing the target in a tightly-managed layout and want the ability to customize both.

@amcclain
Copy link
Member Author

I'd propose the following mildly-breaking (but not in a bad way) API changes:

  • Existing targetText prop accepts either a string (as it does now) or a function of the form ({draggedFiles}) => ReactNode.
    • If a string, text will be shown at all times, even when a set of files is being dragged over the target. This is the mildly breaking part, as the currently generated "drop to add x files" text will not render, but the component should still apply the drag-active class and I don't think any static customized target text will appear obviously wrong.
    • If a function, app developer can customize to return the static text when draggedFiles is empty and any desired custom text when not.
    • If not specified, we should default to a function that will replicate the current defaults.
  • New rejectText prop accepts either a string or function of the form ({rejectedFiles}) => ReactNode.

@leogretz2
Copy link
Contributor

leogretz2 commented Nov 21, 2023

react-dropzone/react-dropzone#752 points to adding reasons for file rejection in the FileRejection object that onDrop and onDropRejected (of React Dropzone) take in react-dropzone version 11.0.0.

@leogretz2 leogretz2 linked a pull request Nov 27, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants