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 <FileInput> triggers onChange twice with latest version of react-dropzone #10402

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

slax57
Copy link
Contributor

@slax57 slax57 commented Dec 9, 2024

Problem

Fix #10401

Analysis

The issue only happens after upgrading react-dropzone to the latest version (14.3.5 at the time of writing). Version 14.2.3 does not show the issue.

At first I thought it seemed like a regression from the react-dropzone lib, but on second thought, I think we should not forward the onChange prop to the wrapping <Labeled> anyways. We should only call onChange ourselves, to make sure it's always fed with a File object or array.

Solution

Exclude the onChange prop from the ...rest parameters.

How To Test

Locally update the react-dropzone version: yarn up react-dropzone.
Then, run one of the following stories, and make sure they only trigger onChange once, with either a File object or array.

Additional Checks

  • The PR targets master for a bugfix, or next for a feature
  • The PR includes unit tests (if not possible, describe why) -> not possible, current unit tests about setting a file are disabled because jsdom doesn't support the drop event
  • The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date

Also, please make sure to read the contributing guidelines.

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@slax57 slax57 added the RFR Ready For Review label Dec 9, 2024
@djhi djhi added this to the 5.4.2 milestone Dec 9, 2024
@djhi djhi merged commit 30bee8b into master Dec 9, 2024
15 checks passed
@djhi djhi deleted the fix-FileInput-onChange branch December 9, 2024 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileInput onChange prop return more than one event type
2 participants