-
Notifications
You must be signed in to change notification settings - Fork 151
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(FileUpload): revert to not calling onChange on file remove #2521
Conversation
🦋 Changeset detectedLatest commit: 8fa9c0c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ PR title follows Conventional Commits specification. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8fa9c0c:
|
@@ -377,11 +372,8 @@ const _FileUpload: React.ForwardRefRenderFunction<BladeElementRef, FileUploadPro | |||
size={size} | |||
onRemove={() => { | |||
const newFiles = selectedFiles.filter(({ id }) => id !== file.id); | |||
flushSync(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are also removing flushSync?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup we added it to fix the onChange args right? now we are not calling onChange on remove
I verified the changes. Seems to work fine. Lets merge |
Description
Issue Context: https://razorpay.slack.com/archives/CMQ3RBHEU/p1738568779980839?thread_ts=1738140484.133379&cid=CMQ3RBHEU
Timeline:
In 11.34.1: We did not call
onChange
on removing of file. OnlyonRemove
was calledIn 11:36.2: We added dispatchEvent call which started calling onChange on onRemove
In 12.4.0: We released a fix thinking onChange call was expected behaviour and we just updated the state value for it
So for consumers upgrading from 11.34.1 -> 12.4.0, it becomes breaking change because onChange was not previously called
Why is onChange getting called on dispatchEvent?
Hmm this is wild. So React apparently treats dispatchEvent with input type="text" differently than it treats input type="file"
Reproduction: https://codesandbox.io/p/sandbox/friendly-ishizaka-yk7mm3
I've added more details in issue here - facebook/react#32300
Changes
New behaviour: We'll revert back to behaviour of 11.34.1 where onChange is not called on removing file
Additional Information
Component Checklist