Open olizarevichroman opened 1 year ago
I think it has to be inside a form if you want validation, but I'm not sure. Can you look @Mr-Technician?
@ScarletKuro This is unrelated to form validation. There is a call to InputFileChangeEventArgs.GetMultipleFiles
that can throw the exception mentioned in the issue. I suppose catching it and adding the exception to the list of errors might make the most sense. Alternatively we could remove the limit but it remains as a performance safeguard.
In my opinion, the most logical approach would be the possibility to catch it using an ErrorBoundary
, document this feature, and let the user decide how to handle it. However, for unknown reasons, this error doesn't propagate up to the ErrorBoundary
.
@ScarletKuro This is unrelated to form validation. There is a call to
InputFileChangeEventArgs.GetMultipleFiles
that can throw the exception mentioned in the issue. I suppose catching it and adding the exception to the list of errors might make the most sense. Alternatively we could remove the limit but it remains as a performance safeguard.
What is the intension of having MudFileUpload.MaximumFileCount
? As I understand it should be used as input validation as well as MudNumericField.Min/MudNumericField.Max
e.g.
If not then it's not clear why do we need MudFileUpload.Validation
and why MudFileUpload
is treated as from component.
Also I would say if we provide 3 files via MudFileUpload.Files
having MudFileUpload.MaximumFileCount == 2
then we also should have validation error.
@ScarletKuro @Mr-Technician I can provide PR for this issue if needed
What is the intension of having
MudFileUpload.MaximumFileCount
? As I understand it should be used as input validation as well asMudNumericField.Min/MudNumericField.Max
e.g.
My guess it's to override the Microsoft's default-value for GetMultipleFiles
https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.forms.inputfilechangeeventargs.getmultiplefiles?view=aspnetcore-7.0
But @Mr-Technician knows better as he made this this component.
@ScarletKuro is correct, MudFileUpload.MaximumFileCount
is an override for the default parameter of GetMultipleFiles
as linked above. This was my best solution at the time to allow users to increase the limit without removing it entirely and removing the performance safeguard it provides. This being said, if an ErrorBoundary
could catch the exception that would certainly help improve the UX.
A couple of other points:
Min/Max values serve a different purpose in the components that use them. They are used to prevent the input of out-of-range numeric values either by typing or through the spin buttons. There is no way of preventing a user from attempting to attach more or fewer than the allowed number of files.
Standard behavior for other inputs is that when validation fails, the invalid value is still bound to the property and the error is shown. In this case, the Value
can't be set because the underlying args
object threw an exception instead of returning anything. This also means that other validation rules (say, one that requires at least one file) would inform the user that no file was included at all.
Bug type
Component
Component name
MudFileUpload
What happened?
InvalidOperationException
is thrown by the underlyingInputFileChangeEventArgs.GetMultipleFiles
when user select more files that specified byMudFileUpload.MaximumFileCount
Expected behavior
Exception should not be thrown, validation error should be displayed or at least consumer provided callback should be called
Reproduction link
https://try.mudblazor.com/snippet/GucxEAcQoeBTcSMA
Reproduction steps
MaximumFileCount
parameter.Relevant log output
Version (bug)
6.4.1
Version (working)
No response
What browsers are you seeing the problem on?
Chrome
On what operating system are you experiencing the issue?
Mac OSX
Pull Request
Code of Conduct