Skip to content

Commit

Permalink
fix(src/modal/modal-manager.ts): avoid creating modal when not necessary
Browse files Browse the repository at this point in the history
Signed-off-by: James Chien <james@numbersprotocol.io>
  • Loading branch information
shc261392 committed Dec 5, 2024
1 parent a867437 commit 28bc7a2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/modal/modal-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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() {
Expand Down

0 comments on commit 28bc7a2

Please sign in to comment.