Skip to content

Commit eaac515

Browse files
V16/bug/20035 validation context uncaught promise (#20036)
* #20035 Updated validation context example to reflect issue * Fixes #20035 by handling returned promise * just catch if it was rejected --------- Co-authored-by: Niels Lyngsø <[email protected]>
1 parent c6e5df4 commit eaac515

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/Umbraco.Web.UI.Client/examples/validation-context/validation-context-dashboard.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ export class UmbExampleValidationContextDashboardElement extends UmbLitElement {
9090
'City server-error message',
9191
'8dfc2f15-fb9a-463b-bcec-2c5d3ba2d07d',
9292
);
93-
if (this.country == '')
94-
this.validation.messages.addMessage(
95-
'server',
96-
'$.form.tab2.country',
97-
'Country server-error message',
98-
'd98624f6-82a2-4e94-822a-776b44b01495',
99-
);
93+
}
94+
95+
#checkValidity(){
96+
this.validation.validate().then(
97+
() => true,
98+
() => false,
99+
);
100100
}
101101

102102
override render() {
@@ -123,6 +123,8 @@ export class UmbExampleValidationContextDashboardElement extends UmbLitElement {
123123
124124
<uui-button look="primary" color="positive" @click=${this.#handleSave}>Save</uui-button>
125125
<hr />
126+
<uui-button look="primary" color="positive" @click=${this.#checkValidity}>Check valid</uui-button>
127+
<hr />
126128
<h3>Validation Context Messages</h3>
127129
<pre>${JSON.stringify(this.messages ?? [], null, 3)}</pre>
128130
</uui-box>
@@ -179,7 +181,6 @@ export class UmbExampleValidationContextDashboardElement extends UmbLitElement {
179181
type="text"
180182
.value=${this.country}
181183
@input=${(e: InputEvent) => (this.country = (e.target as HTMLInputElement).value)}
182-
${umbBindToValidation(this, '$.form.tab2.country', this.country)}
183184
required></uui-input>
184185
</uui-form-validation-message>
185186
</form>

src/Umbraco.Web.UI.Client/src/packages/core/validation/controllers/validation.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export class UmbValidationController extends UmbControllerBase implements UmbVal
355355
this.#validators.push(validator);
356356
//validator.addEventListener('change', this.#onValidatorChange);
357357
if (this.#validationMode) {
358-
this.validate();
358+
this.validate().catch(() => undefined);
359359
}
360360
}
361361

0 commit comments

Comments
 (0)