Browse Source

fix: Set last_value for check

- Revert https://github.com/frappe/frappe/pull/17390 since it used to set this.value before triggering change events... due to this this.last_value & this.value was having same value in change events of some control (eg. link field)
- set_input has the responsibility to set this.value and this.last_value properly.

(cherry picked from commit 2e91e92227)
version-14
Suraj Shetty 2 years ago
committed by Mergify
parent
commit
a1609abca7
3 changed files with 3 additions and 4 deletions
  1. +1
    -0
      frappe/public/js/frappe/form/controls/attach.js
  2. +0
    -3
      frappe/public/js/frappe/form/controls/base_control.js
  3. +2
    -1
      frappe/public/js/frappe/form/controls/check.js

+ 1
- 0
frappe/public/js/frappe/form/controls/attach.js View File

@@ -89,6 +89,7 @@ frappe.ui.form.ControlAttach = class ControlAttach extends frappe.ui.form.Contro
}

set_input(value, dataurl) {
this.last_value = this.value;
this.value = value;
if (this.value) {
this.$input.toggle(false);


+ 0
- 3
frappe/public/js/frappe/form/controls/base_control.js View File

@@ -278,9 +278,6 @@ frappe.ui.form.Control = class BaseControl {
} else {
if (this.doc) {
this.doc[this.df.fieldname] = value;
} else {
// case where input is rendered on dialog where doc is not maintained
this.value = value;
}
this.set_input(value);
return Promise.resolve();


+ 2
- 1
frappe/public/js/frappe/form/controls/check.js View File

@@ -31,11 +31,12 @@ frappe.ui.form.ControlCheck = class ControlCheck extends frappe.ui.form.ControlD
return cint(value);
}
set_input(value) {
this.last_value = this.value;
value = cint(value);
this.value = value;
if (this.input) {
this.input.checked = value ? 1 : 0;
}
this.last_value = value;
this.set_mandatory(value);
this.set_disp_area(value);
}


Loading…
Cancel
Save