Skip to content

Input with type="file" and two-way binding doesn't track empty fileList #8316

Closed
@TGlide

Description

@TGlide

Describe the bug

If you have an input like so:

<input type="file" bind:files bind:this={input}>

And set files to null or (new DataTransfer()).files, after having chosen a file, input.files still contains the file chosen. The only way to properly reset both files and input.files is setting them both to (new DataTransfer()).files.

Reproduction

https://svelte.dev/repl/c0813e09c2f744e499e86975c9eea13f?version=3.55.1

Logs

No response

System Info

Browsers: Firefox 110.0; Chrome 110.0.5481.177
OS: Window 10
Svelte Version: 3.55.1

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions