Skip to content

EspoCRM – Open Source CRM Application

date after set on change

Yuri Kuznetsova01f3333b34a
diff --git a/client/src/views/fields/date.js b/client/src/views/fields/date.js
index 2681c3315e..d9266ef841 100644
--- a/client/src/views/fields/date.js
+++ b/client/src/views/fields/date.js
@@ -144,6 +144,20 @@ class DateFieldView extends BaseFieldView {
// Timeout prevents the picker popping one when the duration field adjusts the date end.
setTimeout(() => {
+ /** @type {string} */
+ const from = this.model.attributes[this.params.after];
+ /** @type {string} */
+ const currentValue = this.model.attributes[this.name];
+
+ if (
+ from &&
+ currentValue &&
+ this.getDateTime().toMomentDate(currentValue)
+ .isBefore(this.getDateTime().toMomentDate(from))
+ ) {
+ this.model.set(this.name, from);
+ }
+
this.datepicker.setStartDate(this.getStartDateForDatePicker());
}, 100);
});