Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Pass input multiple into the native element #75

Closed
bcallaghan-et opened this issue Jun 23, 2020 · 4 comments
Closed

Pass input multiple into the native element #75

bcallaghan-et opened this issue Jun 23, 2020 · 4 comments
Labels
good first issue Good for newcomers project: forms Relates to the project forms type: bug/fix Something isn't working

Comments

@bcallaghan-et
Copy link

The input attribute multiple is much simpler to use than the HTML native attribute. However, setting [multiple]="true" does not actually allow the user to select multiple files. All the input setting does currently is change the name of the form field in the final result. Please use the value of multiple to add or remove the native attribute to the underlying input.

@Input() multiple: boolean | string;

@KostyaTretyak KostyaTretyak added project: forms Relates to the project forms type: bug/fix Something isn't working good first issue Good for newcomers labels Jun 23, 2020
@KostyaTretyak
Copy link
Owner

In v2.1.0 this bug is fixed.

@bcallaghan-et
Copy link
Author

@KostyaTretyak Unfortunately, this change doesn't work in all cases. Modern browsers only check for the existence of the multiple attribute and don't actually read its value. Thus, setting a value of multiple="false" still allows multiple files to be selected. The only way to disable this behavior is to remove the attribute entirely.

@bcallaghan-et
Copy link
Author

@KostyaTretyak After some more testing, I found that this change also prevents my previous workaround of setting the attribute manually no longer works, as the input file directive will overwrite my value. I was previously using [attr.multiple]="allowMultiple ? '' : null" to set or remove the attribute as appropriate.

@KostyaTretyak KostyaTretyak reopened this Jun 23, 2020
@KostyaTretyak
Copy link
Owner

Ok, now I see. As workaround you can set multiple="" or multiple="null". Now I will try to fix it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers project: forms Relates to the project forms type: bug/fix Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants