-
Notifications
You must be signed in to change notification settings - Fork 184
Description
Is this a regression?
Yes
Severity
🟠 Major – significantly affects usability
Please provide the branch(es) you discovered this issue in
v93
Environment Details
Chrome, Edge, Windows 11, v93 latest update, v10
Please provide a minimal set of steps to reproduce the issue
- Add a product to the shopping cart.
- Set a “Valid until” date and save.
- Reopen the sidesheet and delete the “Valid until” date by selecting it and clearing the field.
- Save the changes.
- Reopen the sidesheet. The date is still set instead of being cleared.
Note:
This issue does not only occur in the shopping cart but affects all date fields.
Description
It is not possible to directly delete a date from a date field once it has been set. The date can only be removed by first selecting a different date using the DatePicker (without saving), and then deleting that newly selected date by selecting the value in the field and clearing it.
Describe what you expected to happen versus what actually happened
The date field should be able to be deleted directly.
Relevant logs or console output
Add a screenshot(s) if that helps illustrate the problem
No response
Suggested Fix
This quick fix works for me, change (value === resetMoment && !value) to (value && (value === resetMoment)).
edit-date.component.ts
private async writeValue(value: Moment | undefined): Promise<void> {
const resetMoment = this.resetValue ? moment(this.resetValue) : undefined;
if (this.control.errors || value?.isSame(resetMoment) || (value === resetMoment && !value)) {
return;
}The issue occurs because resetMoment is undefined when the date is initially deleted, and value also is undefined due to the deletion of the date. As a result, the code enters this block. Only after the date has been changed once does resetMoment contain a date value, which prevents the code from entering this block and allows the date to be updated to an empty value (undefined).
It is only necessary to check whether value is equal to resetMoment if value is truthy.
Anything else?
No response
Before submitting...
- I have searched for existing issues that match this one on github and on the community support page
- I have included all necessary details to reproduce this issue