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: fileUpload onRemove clashes with onChange [FC-1234] #2464

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tewarig
Copy link
Contributor

@tewarig tewarig commented Jan 8, 2025

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

  • Update Component Status Page
  • Perform Manual Testing in Other Browsers
  • Add KitchenSink Story
  • Add Interaction Tests (if applicable)
  • Add changeset

Copy link

changeset-bot bot commented Jan 8, 2025

🦋 Changeset detected

Latest commit: d66fd3e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@razorpay/blade Patch

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

Copy link
Contributor

github-actions bot commented Jan 8, 2025

✅ PR title follows Conventional Commits specification.

Copy link

codesandbox-ci bot commented Jan 8, 2025

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:

Sandbox Source
razorpay/blade: basic Configuration

@rzpcibot
Copy link
Collaborator

rzpcibot commented Jan 8, 2025

Bundle Size Report

Updated Components
Status Component Base Size (kb) Current Size (kb) Diff
Badge 0.893 0.892 -0.001 KB
FileUpload 17.833 17.856 +0.023 KB

Generated by 🚫 dangerJS against d66fd3e

@tewarig tewarig changed the title fix: fileUpload onRemove clashes with onChange fix: fileUpload onRemove clashes with onChange [FC-1234] Jan 9, 2025
@@ -1,4 +1,5 @@
import { useState, useCallback, useMemo, useRef, forwardRef } from 'react';
import { flushSync } from 'react-dom';
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broken csb link ^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool

@saurabhdaware
Copy link
Member

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?

@tewarig
Copy link
Contributor Author

tewarig commented Jan 17, 2025

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.
no. regarding arguments nothing have changed

'@razorpay/blade': patch
---

fix: fileupload on remove clashes with onchage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saurabhdaware note added

anuraghazra
anuraghazra previously approved these changes Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants