carbon-design-system / carbon-components-svelte

Svelte implementation of the Carbon Design System
https://svelte.carbondesignsystem.com
Apache License 2.0
2.71k stars 261 forks source link

FileUploader: `files` not fully synchronized with underlying input #1785

Open brunnerh opened 1 year ago

brunnerh commented 1 year ago

In the "edit" state, files can be removed, but the invisible file input will still contain them, so with a regular form post, they are still submitted. Programmatically changing the files property will also have no effect on the input. FileUploaderDropContainer should have the same issue.

REPL demo

A note on a potential fix approach: The input.files property can be set, but FileList objects cannot easily be constructed (at least last time I checked). A common way around this is to use a DataTransfer.

const data = new DataTransfer(); 
data.items.add(file);
input.files = data.files;

Related/overlap with: