From 28bc7a23e5336c6a5a4803c29c724c81849a7ed0 Mon Sep 17 00:00:00 2001 From: James Chien Date: Thu, 5 Dec 2024 12:32:07 +0800 Subject: [PATCH] fix(src/modal/modal-manager.ts): avoid creating modal when not necessary Signed-off-by: James Chien --- src/modal/modal-manager.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/modal/modal-manager.ts b/src/modal/modal-manager.ts index 76cc0af..a2bf385 100644 --- a/src/modal/modal-manager.ts +++ b/src/modal/modal-manager.ts @@ -64,10 +64,10 @@ export class ModalManager { } removeModal(): void { - const modal = this.getModal(); - modal.modalHidden = true; + if (!this.modalElement) return; + this.modalElement.modalHidden = true; this.unregisterRootClickListener(); - modal.remove(); + this.modalElement.remove(); this.modalElement = null; } @@ -87,9 +87,8 @@ export class ModalManager { assetModel: AssetModel | undefined, setAsLoaded: boolean ) { - const modal = this.getModal(); - if (!assetModel) return; - modal.updateAsset(assetModel, setAsLoaded); + if (!this.modalElement || !assetModel) return; + this.modalElement.updateAsset(assetModel, setAsLoaded); } private registerRootClickListener() {