Skip to content

Conversation

@Tiss29
Copy link

@Tiss29 Tiss29 commented Oct 28, 2025

Fixed DatePicker 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 #20722

Fix DatePicker components to not show invalid/warn states when disabled or readonly

Changelog

New

  • Added tests in DatePicker-test.js and date-picker_spec.ts to verify invalid/warn states are not shown when disabled or readonly.

Changed

  • Added disabled prop to DatePicker.tsx and modified child component props to include conditions for invalid/warn states.
  • Updated DatePickerInput.tsx to not apply invalid/warn CSS classes when disabled/readonly.
  • Modified useNormalizedInputProps.tsx to check for disabled state when setting invalid/warn properties.
  • Updated date-picker-input.ts to check for disabled state in normalizedProps.
  • Added CSS rules in _date-picker.scss to remove invalid/warn styling for disabled and readonly inputs.
  • Added CSS rules in date-picker.scss for web components implementation.

Testing / Reviewing

  • Access DatePicker on storybook 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 DatePicker 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.
@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2025

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

@netlify
Copy link

netlify bot commented Oct 28, 2025

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

Name Link
🔨 Latest commit 7394ff7
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/692961b2af85060008ec8f93
😎 Deploy Preview https://deploy-preview-20828--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 28, 2025

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 7394ff7
🔍 Latest deploy log https://app.netlify.com/projects/carbon-elements/deploys/692961b22c867d000851860e
😎 Deploy Preview https://deploy-preview-20828--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 28, 2025

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7394ff7
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/692961b27ee39000075586eb
😎 Deploy Preview https://deploy-preview-20828--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.

@Tiss29
Copy link
Author

Tiss29 commented Oct 28, 2025

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

@Tiss29
Copy link
Author

Tiss29 commented Oct 28, 2025

recheck

@Tiss29 Tiss29 marked this pull request as ready for review October 28, 2025 12:53
@Tiss29 Tiss29 requested a review from a team as a code owner October 28, 2025 12:53
@Tiss29
Copy link
Author

Tiss29 commented Oct 28, 2025

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

Copy link
Contributor

@maradwan26 maradwan26 left a comment

Choose a reason for hiding this comment

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

Thanks for contributing! Just some comments on coding conventions and best practices

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

@Tiss29 You'll need to sign the DCO with both accounts used to pass the DCO check

@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.32%. Comparing base (50b0404) to head (7394ff7).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20828      +/-   ##
==========================================
- Coverage   92.62%   92.32%   -0.30%     
==========================================
  Files         515      529      +14     
  Lines       38222    40630    +2408     
  Branches     5805     5841      +36     
==========================================
+ Hits        35403    37513    +2110     
- Misses       2670     2968     +298     
  Partials      149      149              
Flag Coverage Δ
main-packages 85.60% <100.00%> (-0.01%) ⬇️
web-components 96.06% <100.00%> (-0.82%) ⬇️

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.

Fixed DatePicker 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.
@Tiss29
Copy link
Author

Tiss29 commented Oct 29, 2025

@maradwan26 I have a doubt regarding the requirement to “sign the DOC with both accounts.”
Could you please clarify which accounts specifically need to sign it?

@maradwan26
Copy link
Contributor

maradwan26 commented Oct 29, 2025

@Tiss29 The DCO checker says you need to sign it with @Tiss-Joseph because there are commits authored by that account

@Tiss-Joseph
Copy link

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

Copy link
Contributor

@maradwan26 maradwan26 left a comment

Choose a reason for hiding this comment

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

  • The invalid outline still shows with the disabled and readonly states in Web Components
Screenshot 2025-10-30 at 1 15 29 PM
  • There are also still some added styles in this PR that should be removed as this implementation should only be done in the component file.

  • Tests are failing for React

Tiss-Joseph and others added 3 commits November 5, 2025 20:29
- Fix invalid outline showing with disabled/readonly states in Web Components
- Remove duplicate styles from shared _date-picker.scss
- Fix failing React tests by moving props to DatePickerInput
- Remove unused disabled prop from DatePicker.tsx
- Move Web Components tests to correct __tests__ directory
- Remove accidental comment from test file
@Tiss29
Copy link
Author

Tiss29 commented Nov 6, 2025

@maradwan26 Could please check

Copy link
Contributor

@maradwan26 maradwan26 left a comment

Choose a reason for hiding this comment

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

Screenshot 2025-11-06 at 12 24 50 PM

Invalid outline shows when disabled/readonly is set to "true" in Web Components

@Tiss29
Copy link
Author

Tiss29 commented Nov 6, 2025

@maradwan26 in my web component action I couldn't see invalid
Screenshot 2025-11-06 at 11 36 26 PM
do I need to enable something while running storybook

@maradwan26
Copy link
Contributor

@Tiss29

The control for invalid is missing in the story, but you can manually set it via inspect element, then set disabled to true with the control panel

Screenshot 2025-11-06 at 1 18 00 PM

You can also add the controls in

date-picker/date-picker.stories.ts

Tiss29 and others added 2 commits November 7, 2025 00:47
- Fix test file to use @open-wc/testing fixture pattern
- Fix invalid outline showing when disabled or readonly is true
- Add invalid/invalidText controls to Storybook stories
@Tiss29
Copy link
Author

Tiss29 commented Nov 6, 2025

@maradwan26 Please recheck

@maradwan26
Copy link
Contributor

@Tiss29

Tests are failing for web components.

You can run the tests locally by running yarn web-test-runner "src/components/date-picker/__tests__/date-picker-test.js" in packages/web-components

@Tiss29
Copy link
Author

Tiss29 commented Nov 24, 2025

@maradwan26 I fix the test
Screenshot 2025-11-24 at 2 23 14 PM

Copy link
Contributor

@maradwan26 maradwan26 left a comment

Choose a reason for hiding this comment

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

LGTM just a couple final suggestions/tweaks!

Comment on lines 86 to 97
:host(#{$prefix}-date-picker-input[disabled]),
:host(#{$prefix}-date-picker-input[readonly]) {
.#{$prefix}--form-requirement {
display: none;
}

.#{$prefix}--date-picker__input--invalid,
.#{$prefix}--date-picker__input--warn {
border-block-end: 1px solid transparent;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
:host(#{$prefix}-date-picker-input[disabled]),
:host(#{$prefix}-date-picker-input[readonly]) {
.#{$prefix}--form-requirement {
display: none;
}
.#{$prefix}--date-picker__input--invalid,
.#{$prefix}--date-picker__input--warn {
border-block-end: 1px solid transparent;
}
}

Same here, this is already accounted for in the component .ts file

Copy link
Author

Choose a reason for hiding this comment

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

okay I will remove them

beforeEach(async () => {
render(defaultTemplate(), document.body);
await Promise.resolve();
datePicker = document.body.querySelector('cds-date-picker');
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should be good to leave this file unchanged.

Copy link
Author

Choose a reason for hiding this comment

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

okay will revert

@Tiss29
Copy link
Author

Tiss29 commented Nov 28, 2025

@maradwan26 @alisonjoseph Please check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest See https://hacktoberfest.com/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants