-
Notifications
You must be signed in to change notification settings - Fork 13
fix(dbinput): inserting an empty string doesn't reset date form fields #5440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(dbinput): inserting an empty string doesn't reset date form fields #5440
Conversation
🦋 Changeset detectedLatest commit: a7129d0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
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 |
There was a problem hiding this 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
writeValueoverwrite 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(''); |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
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.
| to: | ||
| 'writeValue(value: any) {\n' + | ||
| 'if (!value && (this.type() === "date" ||\n' + | ||
| 'if (!value && value !== "" && (this.type() === "date" ||\n' + |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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
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