Skip to content

[fix]File Input with Ref does not allow readding a file after clearing the file. #3089

@Steven7926

Description

@Steven7926

ReactUSWDS Version & USWDS Version:

ReactUSWDS: Most current
USWDS: 3.7.1

Describe the bug

Currently, if a user uses the FileInput component with a ref to expose the imperative handle to allow for clearing files through some clear method, once the file is cleared and the user attempt to upload a new file, the new file will not upload.

The handle event will not fire at all.

this is because the exposed clear files function simply clears the state of the files tracked by the component but does not clear the inputs value.
Since the inputs value is not cleared, and is the same value as the previous event, a new event is not fired.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://trussworks.github.io/react-uswds/?path=/story/components-file-input--with-ref-and-custom-handlers
  2. Click on 'choose from folder' and add a file
  3. Click the 'clear' button
  4. Repeat step 2
  5. Notice the new file is not uploaded and the onChange event is not fired

Expected behavior
The onChange event fires and the file has a preview
Screenshots

Additional context

Device and Browser Information (please complete the following information if describing a UI bug):

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working like it's supposed to

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions