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

[joy-ui][RadioGroup] Allow zero number as a value #40344

Merged
merged 8 commits into from
Jan 11, 2024
Merged

[joy-ui][RadioGroup] Allow zero number as a value #40344

merged 8 commits into from
Jan 11, 2024

Conversation

aacevski
Copy link
Contributor

@aacevski aacevski commented Dec 27, 2023

The reason for this change is that the Radio component didn't work when there was a value of 0 since !!0 => false, this way we explicitly check for undefined/null.

Closes: #40342

Before: https://stackblitz.com/edit/react-cs6xw6?file=Demo.tsx
After: https://codesandbox.io/p/sandbox/joy-ui-cra-ts-forked-pjnwf8?file=%2Fsrc%2FApp.tsx%3A25%2C1

Sorry, something went wrong.

The reason for this change is that the Radio component didn't work when there was a value of 0 since !!0 => false, this way we explicitly check for undefined/null.
@mui-bot
Copy link

mui-bot commented Dec 27, 2023

Netlify deploy preview

https://deploy-preview-40344--material-ui.netlify.app/

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 3356b82

@aacevski aacevski changed the title [joy-ui][Radio Group] fix: Changing !!value to value !== undefined && value !== null [joy-ui][Radio Group] Bug when the value provided is number 0 Dec 27, 2023
@danilo-leal danilo-leal changed the title [joy-ui][Radio Group] Bug when the value provided is number 0 [joy-ui][Radio Group] Fix bug when the value provided is number 0 Dec 28, 2023
@danilo-leal danilo-leal added component: radio This is the name of the generic UI component, not the React module! package: joy-ui Specific to @mui/joy labels Dec 28, 2023
@zannager zannager requested a review from siriwatknp December 28, 2023 11:06
Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

Thank you so much for the fix! one last request, can you add a test for this?

@aacevski
Copy link
Contributor Author

aacevski commented Jan 4, 2024

Thank you so much for the fix! one last request, can you add a test for this?

Yep, just added two tests - one is for the initial value and one to check the value when clicking on the Radio elements. 🙌🏼

I also made sure to check if the tests failed with the old code, and they did.

@aacevski aacevski requested a review from siriwatknp January 4, 2024 21:35
@ZeeshanTamboli ZeeshanTamboli added the bug 🐛 Something doesn't work label Jan 10, 2024
@ZeeshanTamboli ZeeshanTamboli changed the title [joy-ui][Radio Group] Fix bug when the value provided is number 0 [joy-ui][RadioGroup] Fix bug when the value provided is number 0 Jan 10, 2024
@ZeeshanTamboli ZeeshanTamboli changed the title [joy-ui][RadioGroup] Fix bug when the value provided is number 0 [joy-ui][RadioGroup] Allow zero number as a value Jan 11, 2024
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you for the contribution!

@ZeeshanTamboli ZeeshanTamboli merged commit 2c0bd02 into mui:master Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: radio This is the name of the generic UI component, not the React module! package: joy-ui Specific to @mui/joy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[joy-ui][Radio Group] Bug when the value provided is number 0
5 participants