diff --git a/js/ui/components/UploadModal.js b/js/ui/components/UploadModal.js index 6cd56475..31590298 100644 --- a/js/ui/components/UploadModal.js +++ b/js/ui/components/UploadModal.js @@ -143,7 +143,11 @@ export class UploadModal { async load({ container } = {}) { if (this.root) { - return this.root; + if (this.root.isConnected) { + return this.root; + } + this.root = null; + this.eventsBound = false; } if (this.loadPromise) { @@ -192,8 +196,12 @@ export class UploadModal { throw new Error("Upload modal markup missing after load."); } + const previousRoot = this.root; this.container = targetContainer; this.root = modal; + if (previousRoot && previousRoot !== modal) { + this.eventsBound = false; + } this.cacheElements(modal); this.setupModalAccessibility();