remember provider host for validation context

This commit is contained in:
Niels Lyngsø
2024-11-05 16:23:55 +01:00
parent 0e5fd13028
commit 3653d61713

View File

@@ -79,13 +79,16 @@ export class UmbValidationController extends UmbControllerBase implements UmbVal
this.messages.removeTranslator(translator);
}
#currentProvideHost?: UmbClassInterface;
/**
* Provide this validation context to a specific controller host.
* This can be used to Host a validation context in a Workspace, but provide it on a certain scope, like a specific Workspace View.
* @param controllerHost {UmbClassInterface}
*/
provideAt(controllerHost: UmbClassInterface): void {
if (this.#currentProvideHost === controllerHost) return;
this.#providerCtrl?.destroy();
this.#currentProvideHost = controllerHost;
this.#providerCtrl = controllerHost.provideContext(UMB_VALIDATION_CONTEXT, this);
}