Skip to content

Conversation

@mfranzke
Copy link
Collaborator

@mfranzke mfranzke commented Nov 11, 2025

Proposed changes

The condition for resetting a date related input wouldn't accept the empty string as a valid value, whereas this works perfectly fine with a native input[type="date"] HTML element.

resolves #5439

Types of changes

  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improvements to existing components or architectural decisions)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Further comments

🔭🐙🐈 Test this branch here: https://design-system.deutschebahn.com/core-web/review/5439-dbinput-inserting-an-empty-string-doesnt-empty-date-form-fields

@mfranzke mfranzke self-assigned this Nov 11, 2025
@mfranzke mfranzke added 🐛bug Something isn't working 👩‍👧‍👦communityFeedback Feedback from community labels Nov 11, 2025
@mfranzke mfranzke linked an issue Nov 11, 2025 that may be closed by this pull request
7 tasks
@changeset-bot
Copy link

changeset-bot bot commented Nov 11, 2025

🦋 Changeset detected

Latest commit: a7129d0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@db-ux/ngx-core-components Patch
@db-ux/core-foundations Patch
@db-ux/core-components Patch
@db-ux/react-core-components Patch
@db-ux/v-core-components Patch
@db-ux/wc-core-components Patch
@db-ux/core-stylelint Patch
@db-ux/core-migration Patch
@db-ux/agent-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added 📺showcases Changes to 1-n showcases 🏘components and removed 🅰angular labels Nov 11, 2025
@mfranzke mfranzke enabled auto-merge (squash) November 11, 2025 17:28
@mfranzke mfranzke moved this from 🏗 In progress to 🎁 Ready for review in UX Engineering Team Backlog Nov 11, 2025
@mfranzke mfranzke requested a review from Copilot November 11, 2025 17:28
@mfranzke mfranzke changed the title 5439 dbinput inserting an empty string doesnt empty date form fields fix(dbinput): inserting an empty string doesn't empty date form fields Nov 11, 2025
@mfranzke mfranzke changed the title fix(dbinput): inserting an empty string doesn't empty date form fields fix(dbinput): inserting an empty string doesn't reset date form fields Nov 11, 2025
@github-actions github-actions bot added the 📕documentation Improvements or additions to documentation label Nov 11, 2025
Copilot finished reviewing on behalf of mfranzke November 11, 2025 17:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where setting an empty string value on Angular date input fields would not clear the field, which differs from the native HTML input[type="date"] behavior. The fix modifies the writeValue method's condition to allow empty strings to pass through and clear date-related input types.

  • Modified the Angular-specific writeValue overwrite to not return early when an empty string is passed for date/time input types
  • Updated the Angular showcase to demonstrate resetting date inputs with an empty string

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/components/scripts/post-build/components.ts Fixed the condition in the Angular writeValue overwrite to allow empty strings to clear date/time/week/month/datetime-local inputs
showcases/angular-showcase/src/app/components/form/form.component.ts Updated the resetValues method to reset the date input field to an empty string instead of 'reset'

this.form.get('input')?.setValue('reset');
this.form.get('textarea')?.setValue('reset');
this.form.get('dateinput')?.setValue('reset');
this.form.get('dateinput')?.setValue('');
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

According to the custom coding guidelines, when modifying existing components, you should adapt changes into the showcases/vue-showcase, showcases/angular-showcase and showcases/react-showcase folders. The Vue showcase's Form.vue and React showcase's form/index.tsx should also demonstrate the ability to reset date inputs to an empty string, similar to this Angular showcase change.

Copilot generated this review using guidance from repository custom instructions.
to:
'writeValue(value: any) {\n' +
'if (!value && (this.type() === "date" ||\n' +
'if (!value && value !== "" && (this.type() === "date" ||\n' +
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

According to the custom coding guidelines, you should start by writing a test to verify your solution. Consider adding a test in packages/components/src/components/input/input.spec.tsx that verifies date inputs can be cleared by setting the value to an empty string, ensuring this behavior matches native input[type="date"] elements.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copilot AI mentioned this pull request Nov 11, 2025
5 tasks
Copy link
Contributor

Copilot AI commented Nov 11, 2025

@mfranzke I've opened a new pull request, #5441, to work on those changes. Once the pull request is ready, I'll request review from you.

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

Labels

🐛bug Something isn't working 👩‍👧‍👦communityFeedback Feedback from community 🏘components 📕documentation Improvements or additions to documentation 📺showcases Changes to 1-n showcases

Projects

Status: 🎁 Ready for review

Development

Successfully merging this pull request may close these issues.

DBInput: inserting an empty string doesn't empty date form fields

2 participants