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

six-file-upload successs event should always return an array of files #104

Open
FabianKueng opened this issue Sep 12, 2023 · 0 comments
Open

Comments

@FabianKueng
Copy link
Contributor

What problem does this feature solve?

Currently the six-file-upload component exposes an event six-file-upload-success, that returns a CustomEvent of type SixFileUploadSuccessPayload. This is a union type of IMultipleFiles | ISingleFile (these types are not exported), where the former has a property called files and the latter a property called file, depending on whether the multiple flag is set.

When using the six-file-upload component, it is difficult to access these properties/events in a type safe manner.

What does the proposed API look like?

My suggestion would be to get rid of IMultipleFiles and ISingleFile and change the interface of SixFileUploadSuccessPayload to be the following:

export interface SixFileUploadSuccessPayload {
  files: FileList;
}

The event six-file-upload-success should always return an array of files in its event payload. If the component has the property multiple set to false, there will only be one file in the array.

If the change would be implemented like this, this would be a breaking change and we would have to think about adding an additional event and deprecate the current one, or something similar to this.
Additional one could argue, that we could combine the success/failure event (not sure what is the best practice here) and expose just one event which contains a failure/success response and/or the uploaded files. This would force the user to actually handle the failure case. Currently the user is not required to handle the failure case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant