fix: has-error respects both invalid and mandatory
previously set_invalid would remove (if there was no invalid entry) has-error class which were set by set_mandatory fixes #35789
This commit is contained in:
parent
95283be9f5
commit
5c704c3d87
1 changed files with 6 additions and 2 deletions
|
|
@ -277,7 +277,9 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control
|
|||
// set has-error if dialog primary button is clicked
|
||||
if (this.layout && this.layout.is_dialog && !this.layout.primary_action_fulfilled) return;
|
||||
|
||||
this.$wrapper.toggleClass("has-error", Boolean(this.df.reqd && is_null(value)));
|
||||
const is_invalid = this.$wrapper.hasClass("has-error-invalid");
|
||||
this.$wrapper.toggleClass("has-error-mandatory", Boolean(this.df.reqd && is_null(value)));
|
||||
this.$wrapper.toggleClass("has-error", is_invalid || Boolean(this.df.reqd && is_null(value)));
|
||||
}
|
||||
set_invalid() {
|
||||
let invalid = !!this.df.invalid;
|
||||
|
|
@ -286,7 +288,9 @@ frappe.ui.form.ControlInput = class ControlInput extends frappe.ui.form.Control
|
|||
this.$input?.toggleClass("invalid", invalid);
|
||||
this.grid_row.columns[this.df.fieldname].is_invalid = invalid;
|
||||
} else {
|
||||
this.$wrapper.toggleClass("has-error", invalid);
|
||||
const is_mandatory_and_empty = this.$wrapper.hasClass("has-error-mandatory");
|
||||
this.$wrapper.toggleClass("has-error-invalid", invalid);
|
||||
this.$wrapper.toggleClass("has-error", is_mandatory_and_empty || invalid);
|
||||
}
|
||||
}
|
||||
set_required() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue