Skip to content

Commit 6894ff9

Browse files
committed
fix(pat-validation): When removing the error, also clear the error state of all siblings.
1 parent 9eb4cda commit 6894ff9

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/pat/validation/validation.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class Pattern extends BasePattern {
257257

258258
if (!validity_state.customError) {
259259
// No error to handle. Return.
260-
this.remove_error(input, true);
260+
this.remove_error({ input });
261261
return;
262262
}
263263
} else {
@@ -354,15 +354,23 @@ class Pattern extends BasePattern {
354354
}
355355
}
356356

357-
remove_error(input, all_of_group = false, skip_event = false) {
358-
// Remove error message and related referencesfrom input.
357+
remove_error({
358+
input,
359+
all_of_group = true,
360+
clear_state = true,
361+
skip_event = false,
362+
}) {
363+
// Remove error message and related references from input.
359364

360365
let inputs = [input];
361366
if (all_of_group) {
362367
// Get all inputs with the same name - e.g. radio buttons, checkboxes.
363368
inputs = this.inputs.filter((it) => it.name === input.name);
364369
}
365370
for (const it of inputs) {
371+
if (clear_state) {
372+
this.set_error({ input: it, msg: "", skip_event: true });
373+
}
366374
const error_node = it[KEY_ERROR_EL];
367375
it[KEY_ERROR_EL] = null;
368376
error_node?.remove();
@@ -385,7 +393,12 @@ class Pattern extends BasePattern {
385393

386394
set_error_message(input) {
387395
// First, remove the old error message.
388-
this.remove_error(input, false, true);
396+
this.remove_error({
397+
input,
398+
all_of_group: false,
399+
clear_state: false,
400+
skip_event: true
401+
});
389402

390403
// Do not set a error message for a input group like radio buttons or
391404
// checkboxes where one has already been set.

0 commit comments

Comments
 (0)