From fbd798216ad3de1b08ba2c6addb4672160b746b5 Mon Sep 17 00:00:00 2001 From: Lars Olav Torvik Date: Tue, 3 Dec 2024 15:21:43 +0100 Subject: [PATCH] Make sure we return the correct valid status from setComponentValidity, also make sure we use showErrorMessages to define if we should set error message instead of formios: (!this.isEmpty(this.defaultValue) || dirty || !this.pristine) --- .../src/formio/components/base/BaseComponent.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/shared-components/src/formio/components/base/BaseComponent.ts b/packages/shared-components/src/formio/components/base/BaseComponent.ts index 22d0b7941..86c44e4b8 100644 --- a/packages/shared-components/src/formio/components/base/BaseComponent.ts +++ b/packages/shared-components/src/formio/components/base/BaseComponent.ts @@ -226,6 +226,16 @@ class BaseComponent extends FormioReactComponent { this.rerender(); } + setComponentValidity(messages, dirty, silentCheck) { + if (messages.length && (!silentCheck || this.error) && this.showErrorMessages()) { + this.setCustomValidity(messages, dirty); + } else { + this.setCustomValidity(''); + } + + return this.componentErrors.length === 0; + } + createError(message: string, elementId?: string): ComponentError { return { message,