Skip to content

Conversation

@anuanto966
Copy link
Contributor

@anuanto966 anuanto966 commented Oct 27, 2025

Fixed RadioButton components in both React and Web Components to not show invalid/warn states when in disabled or readonly state, as users cannot interact with these components in those states.

Closes #20730

Changelog

Changed

  • Instead of using readOnly state to check if should display warnings or not, Radio Button now also checks if component is disabled. This way, warnings will not be shown if the component is disabled/readOnly.

Testing / Reviewing

  • Access Radio button on storybook (/?path=/story/components-radio-button--default) and change the state to "Invalid = true" and "disabled = true". The invalid message should not be shown.
  • Repeat above test with "readOnly = true" instead of disabled. The invalid message should not be shown.
  • Repeat the two tests above using "warn = true" instead of "invalid = true". The warning message on both scenarios should not be shown.

PR Checklist

As the author of this PR, before marking ready for review, confirm you:

  • Reviewed every line of the diff
  • Updated documentation and storybook examples
  • Wrote passing tests that cover this change
  • Addressed any impact on accessibility (a11y)
  • Tested for cross-browser consistency
  • Validated that this code is ready for review and status checks should pass

More details can be found in the pull request guide

Fixed RadioButton components in both React and Web Components to not show
invalid/warn states when in disabled or readonly state, as users cannot
interact with these components in those states.
@netlify
Copy link

netlify bot commented Oct 27, 2025

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 20455f8
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/690d6a203fe89a0007d36630
😎 Deploy Preview https://deploy-preview-20810--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Oct 27, 2025

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 20455f8
🔍 Latest deploy log https://app.netlify.com/projects/carbon-elements/deploys/690d6a208ac01f000804a598
😎 Deploy Preview https://deploy-preview-20810--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Oct 27, 2025

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 20455f8
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/690d6a2017fcc80008e822c3
😎 Deploy Preview https://deploy-preview-20810--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

❌ Patch coverage is 98.63014% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.42%. Comparing base (9201e68) to head (20455f8).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...onents/src/components/radio-button/radio-button.ts 98.36% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20810      +/-   ##
==========================================
+ Coverage   92.41%   92.42%   +0.01%     
==========================================
  Files         515      515              
  Lines       37524    37591      +67     
  Branches     5693     5735      +42     
==========================================
+ Hits        34676    34745      +69     
+ Misses       2700     2697       -3     
- Partials      148      149       +1     
Flag Coverage Δ
main-packages 85.55% <100.00%> (+0.01%) ⬆️
web-components 96.73% <98.48%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@riddhybansal riddhybansal left a comment

Choose a reason for hiding this comment

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

Hi This Looks God to me!! Thanks for your contribution 💯

@riddhybansal riddhybansal self-requested a review October 27, 2025 13:43
Copy link
Contributor

@riddhybansal riddhybansal left a comment

Choose a reason for hiding this comment

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

Hey this looks good

Small Suggestions for Improvement
Code Consistency

Consider using useNormalizedInputProps in all components rather than creating separate validation logic:

normalizedProps = useNormalizedInputProps({
id, disabled, readOnly, invalid, invalidText, warn, warnText,
});

Then reference normalizedProps.invalid and normalizedProps.warn for validation states
Our input controls already use this pattern, which makes future fixes simpler (just update the hook once).

Here is the reference #20808

anuanto966 and others added 2 commits October 28, 2025 08:35
Fixed Timepicker components in both React and Web Components to not show
invalid/warn states when in disabled or readonly state, as users cannot
interact with these components in those states.
@anuanto966
Copy link
Contributor Author

Then reference normalizedProps.invalid and normalizedProps.warn for validation states Our input controls already use this pattern, which makes future fixes simpler (just update the hook once).

Here is the reference #20808

Hi @riddhybansal these changes are done. Could you please review . Also can you please add the label hacktoberfest to this PR.

@riddhybansal
Copy link
Contributor

Please run "yarn test -u" in root for test cases to pass.

@riddhybansal riddhybansal added the hacktoberfest See https://hacktoberfest.com/ label Oct 28, 2025
@anuanto966
Copy link
Contributor Author

yarn test -u

@riddhybansal Ran the tests in local and passed
image

@riddhybansal riddhybansal added this pull request to the merge queue Nov 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 7, 2025
@riddhybansal riddhybansal added this pull request to the merge queue Nov 10, 2025
Merged via the queue into carbon-design-system:main with commit b1d5ecd Nov 10, 2025
41 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RadioButton]: Disallow invalid & warn when readonly or disabled

5 participants