-
Notifications
You must be signed in to change notification settings - Fork 147
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 onRemove clashes with onChange [FC-1234] #2464
base: master
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: d66fd3e 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 d66fd3e:
|
@@ -1,4 +1,5 @@ | |||
import { useState, useCallback, useMemo, useRef, forwardRef } from 'react'; | |||
import { flushSync } from 'react-dom'; |
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.
Is flushSync available in React17? If not we won't be able to use it as it will fail on consumer end.
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.
Yes, flushSync was initially added in React 16. I was able to find the PR: facebook/react#10225. However, I think the team didn’t document it.
I have tested this branch on React 17. Here is the sandbox link:
https://codesandbox.io/p/sandbox/blade-testing-template-ky8wfs
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.
Broken csb link ^
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.
@anuraghazra can you try it now?
https://codesandbox.io/p/sandbox/blade-testing-template-ky8wfs
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.
Cool
To confirm, the change post-this would be that onChange will get triggered with latest value after item is removed right? does anything change in arguments we pass to onRemove or arguments passed to onChange in other scenarios? |
yes. now onChange will get triggered with latest value after removing the item. |
.changeset/modern-geckos-relate.md
Outdated
'@razorpay/blade': patch | ||
--- | ||
|
||
fix: fileupload on remove clashes with onchage |
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.
fix: fileupload on remove clashes with onchage | |
fix(FileUpload): fileupload on remove clashes with onchage |
Also can you add a note here for consumers on what exactly we changed in behaviour?
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.
sure
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.
@saurabhdaware note added
Co-authored-by: Saurabh Daware <[email protected]>
Description
fileUpload component's onRemove behavior clashes with onChange.
I believe onChange should be triggered when onRemove is called, but it should provide the latest value instead of returning outdated values. Currently, we are using onRemove to handle file removal. However, ideally, this should be managed by onChange, similar to how an input's onChange event reflects both the addition and removal of characters in a string.
Additional Information
this pr should go with a major release.
Component Checklist