diff --git a/src/core/components/sheet-modal/sheet-modal.ts b/src/core/components/sheet-modal/sheet-modal.ts index 4216224b4..b3c409775 100644 --- a/src/core/components/sheet-modal/sheet-modal.ts +++ b/src/core/components/sheet-modal/sheet-modal.ts @@ -34,6 +34,7 @@ export class CoreSheetModalComponent implements Af private element: HTMLElement; private wrapperElement = new CorePromisedValue(); + private content?: HTMLElement; constructor({ nativeElement: element }: ElementRef) { this.element = element; @@ -61,7 +62,7 @@ export class CoreSheetModalComponent implements Af */ async show(): Promise { const wrapper = await this.wrapperElement; - const element = await AngularFrameworkDelegate.attachViewToDom(wrapper, this.component, this.componentProps ?? {}); + this.content = await AngularFrameworkDelegate.attachViewToDom(wrapper, this.component, this.componentProps ?? {}); await CoreUtils.nextTick(); @@ -71,7 +72,7 @@ export class CoreSheetModalComponent implements Af await CoreUtils.nextTick(); await CoreUtils.wait(300); - const instance = CoreDirectivesRegistry.resolve(element, this.component); + const instance = CoreDirectivesRegistry.resolve(this.content, this.component); if (!instance) { throw new Error('Modal not mounted properly'); @@ -84,10 +85,13 @@ export class CoreSheetModalComponent implements Af * Hide modal. */ async hide(): Promise { + const wrapper = await this.wrapperElement; + this.element.classList.remove('active'); await CoreUtils.nextTick(); await CoreUtils.wait(300); + await AngularFrameworkDelegate.removeViewFromDom(wrapper, this.content); } } diff --git a/src/core/features/fileuploader/components/audio-recorder/audio-recorder.component.ts b/src/core/features/fileuploader/components/audio-recorder/audio-recorder.component.ts index d24111752..85d01340c 100644 --- a/src/core/features/fileuploader/components/audio-recorder/audio-recorder.component.ts +++ b/src/core/features/fileuploader/components/audio-recorder/audio-recorder.component.ts @@ -86,7 +86,11 @@ export class CoreFileUploaderAudioRecorderComponent extends CoreModalComponent { await sheetModal.hide(); + await AngularFrameworkDelegate.removeViewFromDom(container, element); - element.remove(); viewContainer?.removeAttribute('aria-hidden'); });