Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Steven7926 opened this issue Jan 3, 2025 · 0 comments · May be fixed by #3090
Open

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

Steven7926 opened this issue Jan 3, 2025 · 0 comments · May be fixed by #3090
Labels
type: bug Something isn't working like it's supposed to

Comments

@Steven7926
Copy link

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):

@Steven7926 Steven7926 added the type: bug Something isn't working like it's supposed to label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working like it's supposed to
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant