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

[Feature Request]: Allow FileUploader internal files state to be mutated #18223

Open
1 task done
VadimDez opened this issue Dec 9, 2024 · 4 comments · May be fixed by #18267
Open
1 task done

[Feature Request]: Allow FileUploader internal files state to be mutated #18223

VadimDez opened this issue Dec 9, 2024 · 4 comments · May be fixed by #18267
Labels
component: file-uploader needs: community contribution Due to roadmap and resource availability, we are looking for outside contributions on this issue. status: help wanted 👐 type: enhancement 💡

Comments

@VadimDez
Copy link

VadimDez commented Dec 9, 2024

The problem

Right now we can set multiple={true} and select as many files as user wants. No way to limit amount of files to be selected in total.

The solution

Adding a new property max or modifying multiple property to accept a specific number.

Examples

No response

Application/PAL

No response

Business priority

None

Available extra resources

No response

Code of Conduct

Copy link
Contributor

github-actions bot commented Dec 9, 2024

Thank you for submitting a feature request. Your proposal is open and will soon be triaged by the Carbon team.

If your proposal is accepted and the Carbon team has bandwidth they will take on the issue, or else request you or other volunteers from the community to work on this issue.

@tay1orjones
Copy link
Member

Hi @VadimDez, thanks for opening this issue! For the inputs we try to follow what's available natively in the browser. Unfortunately the multiple attribute doesn't have support for a maximum file count/limit, so there's no way to instruct the browser to only allow a certain amount of files in the OS file selection dialog.

I think the best way to approach this would be to run validation after the file(s) upload and present the user an error message if they've selected/uploaded more than what is allowed.

@tay1orjones tay1orjones closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2024
@github-project-automation github-project-automation bot moved this from Triage to Completed 🚢 in Roadmap Dec 9, 2024
@VadimDez
Copy link
Author

VadimDez commented Dec 9, 2024

@tay1orjones thanks for reply, unfortunately internal state is already updated and it's rendering filenames right after the user selects files. I could show an error message, but how do I update the state (files) in FileUploader?

@tay1orjones
Copy link
Member

tay1orjones commented Dec 10, 2024

@VadimDez looks like when FileUploader used to be a class component we exposed a state clearing function via a ref.

const clearFiles = () => {
// A clearFiles function that resets filenames and can be referenced using a ref by the parent.
updateState({ fileNames: [] });
};

That could be added back with a useImperativeHandle, and that function could be extended to support parameters supporting the removal of certain files from the internal state array.

@tay1orjones tay1orjones reopened this Dec 10, 2024
@github-project-automation github-project-automation bot moved this from Completed 🚢 to Triage in Roadmap Dec 10, 2024
@tay1orjones tay1orjones changed the title [Feature Request]: FileUploader max files to be selected [Feature Request]: Allow FileUploader internal files state to be mutated Dec 10, 2024
@tay1orjones tay1orjones added needs: community contribution Due to roadmap and resource availability, we are looking for outside contributions on this issue. and removed status: needs triage 🕵️‍♀️ status: waiting for maintainer response 💬 labels Dec 10, 2024
@tay1orjones tay1orjones moved this to ⏱ Backlog in Design System Dec 10, 2024
@tay1orjones tay1orjones moved this from Triage to Later 🧊 in Roadmap Dec 10, 2024
@tekno0ryder tekno0ryder linked a pull request Dec 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: file-uploader needs: community contribution Due to roadmap and resource availability, we are looking for outside contributions on this issue. status: help wanted 👐 type: enhancement 💡
Projects
Status: ⏱ Backlog
Status: Later 🧊
Development

Successfully merging a pull request may close this issue.

2 participants