Skip to content

fix(DatePicker): fixed disabled state for DatePicker - #21848

Open
suniltc-ibm wants to merge 24 commits into
carbon-design-system:mainfrom
suniltc-ibm:fix/datepicker-read-only
Open

fix(DatePicker): fixed disabled state for DatePicker#21848
suniltc-ibm wants to merge 24 commits into
carbon-design-system:mainfrom
suniltc-ibm:fix/datepicker-read-only

Conversation

@suniltc-ibm

@suniltc-ibm suniltc-ibm commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Closes #21803

DatePicker: disabled state ignored when readOnly is also true

Changelog

Changed

  • Added CSS for Disabled state to take precedence over readonly
  • Updated disabled props
  • Covered test cases
  • Updated all the components to take disabled over readonly state

Testing / Reviewing

Navigate to Date Picker
Click on Default story
Set Disabled control to true
Set Read Only to true
Disabled overwrites Read Only

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

@suniltc-ibm
suniltc-ibm requested a review from a team as a code owner March 17, 2026 10:38
@netlify

netlify Bot commented Mar 17, 2026

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 39b6a31
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/6a6aea6e77ab6b0008408d71
😎 Deploy Preview https://deploy-preview-21848--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@netlify

netlify Bot commented Mar 17, 2026

Copy link
Copy Markdown

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 39b6a31
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/6a6aea6e02c95f0008fae6bc
😎 Deploy Preview https://deploy-preview-21848--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.26%. Comparing base (0a75905) to head (39b6a31).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21848      +/-   ##
==========================================
+ Coverage   89.62%   90.26%   +0.64%     
==========================================
  Files         582      265     -317     
  Lines       53317    40045   -13272     
  Branches     7312     2210    -5102     
==========================================
- Hits        47784    36148   -11636     
+ Misses       5396     3879    -1517     
+ Partials      137       18     -119     
Flag Coverage Δ
main-packages ?
web-components 90.26% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@adamalston adamalston 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.

Could you add testing?

Comment thread packages/react/src/components/DatePickerInput/DatePickerInput.tsx Outdated
Comment thread packages/styles/scss/components/date-picker/_date-picker.scss Outdated
@suniltc-ibm

Copy link
Copy Markdown
Contributor Author

@adamalston Updated code and covered test. Please check.

const prefix = usePrefix();
const normalizedProps: NormalizedInputProps = {
disabled: !readOnly && disabled,
disabled: disabled,

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.

The useNormalizedInputProps hook is used in 11 components. Should this change in precedence be limited to DatePickerInput, or should it also be applied to other consumers of this hook, with corresponding updates to their styles and tests? With the current code, it appears that the TextInput, Select, Dropdown, and the TimePicker input will all render in a read-only state when both props are set to true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's applied to all the components. It fixes the same issue in other components as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@adamalston Can you please review it again

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.

Sure. In the future, re-requesting a review is the most effective way to ensure a pull request appears in my queue.

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.

Test coverage for this change was added only for DatePicker. Could you also add coverage for the other affected components?

Comment thread packages/react/src/components/DatePicker/DatePicker-test.js Outdated
@heloiselui

Copy link
Copy Markdown
Contributor

Hi @suniltc-ibm , thanks for contributing! Could you also add coverage for the other affected components? There are also some merge conflicts that need to be resolved.

@suniltc-ibm
suniltc-ibm force-pushed the fix/datepicker-read-only branch from 03ab0dc to ecc786a Compare May 11, 2026 05:35
@netlify

netlify Bot commented May 11, 2026

Copy link
Copy Markdown

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 39b6a31
🔍 Latest deploy log https://app.netlify.com/projects/carbon-elements/deploys/6a6aea6e7c9a040008a78c9a
😎 Deploy Preview https://deploy-preview-21848--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

Comment thread packages/react/src/components/DatePickerInput/DatePickerInput.tsx Outdated
Comment thread packages/react/src/components/DatePicker/DatePicker-test.js Outdated
Comment thread packages/react/src/components/NumberInput/NumberInput.tsx

@tay1orjones tay1orjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM once checks pass

expect(select.hasAttribute('disabled')).to.be.true;
expect(select.hasAttribute('readonly')).to.be.false;
expect(select.disabled).to.be.true;
expect(select.readOnly).to.be.false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With tests failing, I think this should assert aria-readonly instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed

@netlify

netlify Bot commented Jul 25, 2026

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 39b6a31
🔍 Latest deploy log https://app.netlify.com/projects/v3-carbon-web-components/deploys/6a6aea6e02c95f0008fae6c2
😎 Deploy Preview https://deploy-preview-21848--v3-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@netlify

netlify Bot commented Jul 25, 2026

Copy link
Copy Markdown

Deploy Preview for v2-carbon-react ready!

Name Link
🔨 Latest commit 39b6a31
🔍 Latest deploy log https://app.netlify.com/projects/v2-carbon-react/deploys/6a6aea6e23ebad0008c4b51c
😎 Deploy Preview https://deploy-preview-21848--v2-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

const labelClasses = classNames(`${prefix}--label`, {
[`${prefix}--visually-hidden`]: hideLabel,
[`${prefix}--label--disabled`]: normalizedProps.disabled,
[`${prefix}--label--readonly`]: readOnly,

@adamalston adamalston Jul 28, 2026

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.

${prefix}--label--readonly is still applied when disabled is also true, so the label keeps the read-only styling even though the input now treats disabled as higher precedence. Is that correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@adamalston Thanks for pointing this out. I didn't notice any issue with it earlier, so I had skipped it. I've now updated the code to include the !disabled guard.

const labelClasses = classNames(`${prefix}--label`, {
[`${prefix}--visually-hidden`]: hideLabel,
[`${prefix}--label--disabled`]: disabled,
[`${prefix}--label--readonly`]: readOnly,

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.

${prefix}--label--readonly is still applied when disabled and readOnly are both true, which leaves the label in the old mixed state after the input behavior changed. Is that correct?

const labelClasses = cx(`${prefix}--label`, {
[`${prefix}--visually-hidden`]: hideLabel,
[`${prefix}--label--disabled`]: disabled,
[`${prefix}--label--readonly`]: readOnly,

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.

Same as earlier.

const className = cx({
[`${prefix}--label`]: true,
[`${prefix}--label--disabled`]: disabled,
[`${prefix}--label--readonly`]: readOnly,

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.

Same as earlier.

);
const titleClasses = cx(`${prefix}--label`, {
[`${prefix}--label--disabled`]: disabled,
[`${prefix}--label--readonly`]: readOnly,

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.

Same as earlier.

@suniltc-ibm
suniltc-ibm requested a review from adamalston July 30, 2026 06:08
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.

[Bug] DatePicker: disabled state ignored when readOnly is also true

5 participants