Skip to content

fix(slider): Disallow invalid & warn when readonly or disabled#20784

Merged
riddhybansal merged 21 commits into
carbon-design-system:mainfrom
BiaBiruka:20731-slider-warning
Oct 28, 2025
Merged

fix(slider): Disallow invalid & warn when readonly or disabled#20784
riddhybansal merged 21 commits into
carbon-design-system:mainfrom
BiaBiruka:20731-slider-warning

Conversation

@BiaBiruka

Copy link
Copy Markdown
Contributor

Closes #20731

Fix the behavior for Slider and Two Handle Slider. When component is disabled or readOnly, it should not show waning nor invalid message.

Changelog

Changed

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

Testing / Reviewing

  • Access the Slider playground on storybook (/?path=/story/components-slider--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

…20731)

fix slider to not show warning message when component is disabled or readOnly.
add test cases to not show warnings when disabled or readOnly.
@BiaBiruka BiaBiruka requested a review from a team as a code owner October 22, 2025 23:04
@github-actions

github-actions Bot commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

All contributors have signed the DCO.
Posted by the DCO Assistant Lite bot.

@BiaBiruka

Copy link
Copy Markdown
Contributor Author

I have read the DCO document and I hereby sign the DCO.

@netlify

netlify Bot commented Oct 22, 2025

Copy link
Copy Markdown

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 4fe30fd
🔍 Latest deploy log https://app.netlify.com/projects/carbon-elements/deploys/6900b2e10919260008f61738
😎 Deploy Preview https://deploy-preview-20784--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

netlify Bot commented Oct 22, 2025

Copy link
Copy Markdown

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 4fe30fd
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/6900b2e1d72eab0009870f44
😎 Deploy Preview https://deploy-preview-20784--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.

@riddhybansal riddhybansal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey, thanks for doing this.
This looks great just few changes I feel that needs to be address.

Variable Naming:

Consider renaming isCurrentlyEditable to isInteractive (preferred) or isEditableState.

Additional Test Cases:

Please add tests to verify:

  • Should not set aria-invalid when disabled with invalid/warn prop
  • Should not set aria-invalid when readOnly with invalid/warn prop

Consider doing same fix for web-component as well.

@BiaBiruka

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback!
The issues have been fixed and are ready for review again. Please let me know if there is anything else I can improve!

@riddhybansal

Copy link
Copy Markdown
Contributor

Can you please do the same fix for the web-component slider as well.

@netlify

netlify Bot commented Oct 23, 2025

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 4fe30fd
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/6900b2e1778f610008e4ad85
😎 Deploy Preview https://deploy-preview-20784--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.

@codecov

codecov Bot commented Oct 23, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.18310% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.33%. Comparing base (766e563) to head (4fe30fd).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/react/src/components/Slider/Slider.tsx 97.56% 1 Missing ⚠️
...b-components/src/components/slider/slider-input.ts 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20784      +/-   ##
==========================================
- Coverage   92.46%   92.33%   -0.14%     
==========================================
  Files         508      511       +3     
  Lines       35753    37244    +1491     
  Branches     5673     5668       -5     
==========================================
+ Hits        33058    34388    +1330     
- Misses       2550     2709     +159     
- Partials      145      147       +2     
Flag Coverage Δ
main-packages 85.50% <97.67%> (+0.01%) ⬆️
web-components 96.67% <96.42%> (-0.53%) ⬇️

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.

@BiaBiruka

Copy link
Copy Markdown
Contributor Author

Done!
Just wanted to clarify one thing... Some components within the web-components package have unit tests, while others don't (the slider doesn't). Checking the Jest configuration, I noticed that the tests for this package are being ignored. Should I create them anyway?

@riddhybansal

Copy link
Copy Markdown
Contributor

Done! Just wanted to clarify one thing... Some components within the web-components package have unit tests, while others don't (the slider doesn't). Checking the Jest configuration, I noticed that the tests for this package are being ignored. Should I create them anyway?

Yeah we are working on creating test files for all components for web-components. We have a whole of an epic for that you can go ahead and add test file for slider and add these test cases in it.

add test cases to not show warnings when disabled or readOnly (web-components).
@BiaBiruka

Copy link
Copy Markdown
Contributor Author

Ok!
Test cases for invalid and warn states created.

@riddhybansal riddhybansal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for your contribution.

@riddhybansal riddhybansal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you please add these test cases

Please add tests to verify:

Should not set aria-invalid when disabled with invalid/warn prop
Should not set aria-invalid when readOnly with invalid/warn prop

improve tests for two handle slider to check for data-invalid prop.
@BiaBiruka

BiaBiruka commented Oct 27, 2025

Copy link
Copy Markdown
Contributor Author

Can you please add these test cases

Please add tests to verify:

Should not set aria-invalid when disabled with invalid/warn prop Should not set aria-invalid when readOnly with invalid/warn prop

Done!

I also refactored the fix to use the normalizedProps hook in order to follow the same pattern requested on my other PR (#20806).

Quick question: for the IBM hacktoberfest event we were requested to add a "hacktoberfest" label on the pull requests for easier tracking of what we made. Would that be possible?

@riddhybansal riddhybansal added the hacktoberfest See https://hacktoberfest.com/ label Oct 27, 2025
@riddhybansal

Copy link
Copy Markdown
Contributor

Can you please add these test cases
Please add tests to verify:
Should not set aria-invalid when disabled with invalid/warn prop Should not set aria-invalid when readOnly with invalid/warn prop

Done!
 I also refactored the fix to use the normalizedProps hook in order to follow the same pattern requested on my other PR (#20806).

Quick question: for the IBM hacktoberfest event we were requested to add a "hacktoberfest" label on the pull requests for easier tracking of what we made. Would that be possible?

Thank you !! That is just perfect !!

@riddhybansal riddhybansal added this pull request to the merge queue Oct 28, 2025
Merged via the queue into carbon-design-system:main with commit bc87e48 Oct 28, 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

hacktoberfest See https://hacktoberfest.com/ status: ready to merge 🎉

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants