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ø <niels.lyngso@gmail.com>
This commit is contained in:
@@ -90,13 +90,13 @@ export class UmbExampleValidationContextDashboardElement extends UmbLitElement {
|
||||
'City server-error message',
|
||||
'8dfc2f15-fb9a-463b-bcec-2c5d3ba2d07d',
|
||||
);
|
||||
if (this.country == '')
|
||||
this.validation.messages.addMessage(
|
||||
'server',
|
||||
'$.form.tab2.country',
|
||||
'Country server-error message',
|
||||
'd98624f6-82a2-4e94-822a-776b44b01495',
|
||||
);
|
||||
}
|
||||
|
||||
#checkValidity(){
|
||||
this.validation.validate().then(
|
||||
() => true,
|
||||
() => false,
|
||||
);
|
||||
}
|
||||
|
||||
override render() {
|
||||
@@ -123,6 +123,8 @@ export class UmbExampleValidationContextDashboardElement extends UmbLitElement {
|
||||
|
||||
<uui-button look="primary" color="positive" @click=${this.#handleSave}>Save</uui-button>
|
||||
<hr />
|
||||
<uui-button look="primary" color="positive" @click=${this.#checkValidity}>Check valid</uui-button>
|
||||
<hr />
|
||||
<h3>Validation Context Messages</h3>
|
||||
<pre>${JSON.stringify(this.messages ?? [], null, 3)}</pre>
|
||||
</uui-box>
|
||||
@@ -179,7 +181,6 @@ export class UmbExampleValidationContextDashboardElement extends UmbLitElement {
|
||||
type="text"
|
||||
.value=${this.country}
|
||||
@input=${(e: InputEvent) => (this.country = (e.target as HTMLInputElement).value)}
|
||||
${umbBindToValidation(this, '$.form.tab2.country', this.country)}
|
||||
required></uui-input>
|
||||
</uui-form-validation-message>
|
||||
</form>
|
||||
|
||||
@@ -355,7 +355,7 @@ export class UmbValidationController extends UmbControllerBase implements UmbVal
|
||||
this.#validators.push(validator);
|
||||
//validator.addEventListener('change', this.#onValidatorChange);
|
||||
if (this.#validationMode) {
|
||||
this.validate();
|
||||
this.validate().catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user