V16/hotfix/ensure self destroy before clean up (#19367)

* move destroy to top

* clean up example

* use the unprovide method when disconnecting
This commit is contained in:
Niels Lyngsø
2025-05-21 11:32:34 +02:00
committed by GitHub
parent 2b714d3022
commit 62cedeec13
4 changed files with 16 additions and 17 deletions

View File

@@ -45,21 +45,21 @@ export class UmbExampleValidationContextDashboardElement extends UmbLitElement {
},
'observeValidationMessages',
);
});
// Observe all errors
this.validation.messages.messagesOfPathAndDescendant('$.form').subscribe((value) => {
this.totalErrorCount = [...new Set(value.map((x) => x.path))].length;
});
// Observe all errors
this.observe(this.validation.messages.messagesOfPathAndDescendant('$.form'), (value) => {
this.totalErrorCount = [...new Set(value.map((x) => x.path))].length;
});
// Observe errors for tab1, note that we only use part of the full JSONPath
this.validation.messages.messagesOfPathAndDescendant('$.form.tab1').subscribe((value) => {
this.tab1ErrorCount = [...new Set(value.map((x) => x.path))].length;
});
// Observe errors for tab1, note that we only use part of the full JSONPath
this.observe(this.validation.messages.messagesOfPathAndDescendant('$.form.tab1'), (value) => {
this.tab1ErrorCount = [...new Set(value.map((x) => x.path))].length;
});
// Observe errors for tab2, note that we only use part of the full JSONPath
this.validation.messages.messagesOfPathAndDescendant('$.form.tab2').subscribe((value) => {
this.tab2ErrorCount = [...new Set(value.map((x) => x.path))].length;
});
// Observe errors for tab2, note that we only use part of the full JSONPath
this.observe(this.validation.messages.messagesOfPathAndDescendant('$.form.tab2'), (value) => {
this.tab2ErrorCount = [...new Set(value.map((x) => x.path))].length;
});
}

View File

@@ -219,8 +219,7 @@ export class UmbContextConsumer<
this.#raf = undefined;
}
this.#instance = undefined;
this.#callback?.(undefined);
this.#unprovide();
if (this.#promiseRejecter) {
const hostElement = this._retrieveHost();
this.#promiseRejecter(

View File

@@ -454,6 +454,7 @@ export class UmbValidationController extends UmbControllerBase implements UmbVal
}
override destroy(): void {
super.destroy();
this.#validationMode = false;
if (this.#inUnprovidingState === true) {
return;
@@ -468,6 +469,5 @@ export class UmbValidationController extends UmbControllerBase implements UmbVal
this.#localMessages = undefined;
this.#parentMessages = undefined;
this.#parent = undefined;
super.destroy();
}
}