diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index f979bb2cb5..fa738c8190 100755 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -744,9 +744,24 @@ frappe.ui.form.ControlDate = frappe.ui.form.ControlData.extend({ }, set_formatted_input: function(value) { this._super(value); - if(value - && ((this.last_value && this.last_value !== value) - || (!this.datepicker.selectedDates.length))) { + if(!value) return; + + let should_refresh = this.last_value && this.last_value !== value; + + if (!should_refresh) { + if(this.datepicker.selectedDates.length > 0) { + // if date is selected but different from value, refresh + const selected_date = + moment(this.datepicker.selectedDates[0]) + .format(moment.defaultDateFormat); + should_refresh = selected_date !== value; + } else { + // if datepicker has no selected date, refresh + should_refresh = true; + } + } + + if(should_refresh) { this.datepicker.selectDate(frappe.datetime.str_to_obj(value)); } },