Skip to content

[Blazor] InputFile support for cancel event #58118

@hakenr

Description

@hakenr

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Currently, InputFile does not handle the cancel event in this scenario (#49148):

  1. Click on the file input.
  2. Select a file. OnChange will be invoked.
  3. Click on the file input again.
  4. Click "Cancel" in the file selection window. The file input will be cleared, but OnChange will not be invoked, so the app still thinks a file is selected.

There hasn't been a way to handle this, as there was no signal from the browser about the dialog being canceled. However, there is now a cancel event that can be used.

Describe the solution you'd like

I would like to subscribe to the cancel event of the underlying <input type="file"> and invoke OnChange.Invoke(new()) with an empty list of files.

Additional context

Related issue: havit/Havit.Blazor#884
Related discussion: https://stackoverflow.com/a/76926836/4150304

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.copilot-candidatefeature-blazor-builtin-componentsFeatures related to the built in components we ship or could ship in the future

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions