AAE-47577 Form Spinner persists outside of Automate Form (#12005)

This commit is contained in:
David Olson
2026-06-25 09:58:24 -05:00
committed by GitHub
parent 74d67c39a0
commit 7546aa91a3
2 changed files with 22 additions and 2 deletions
@@ -96,4 +96,18 @@ describe('FormCloudSpinnerService', () => {
const spinners = await rootLoader.getAllHarnesses(MatProgressSpinnerHarness);
expect(spinners.length).toBe(1);
});
it('should dispose the spinner overlay when the host destroyRef fires without a hide event', async () => {
spinnerService.initSpinnerHandling(destroyRef);
formService.toggleFormSpinner.next(showSpinnerEvent);
fixture.detectChanges();
expect(await rootLoader.hasHarness(MatProgressSpinnerHarness)).toBeTrue();
fixture.destroy();
const overlayContainer = document.querySelector('.cdk-overlay-container');
expect(overlayContainer?.querySelector('.cdk-overlay-pane')).toBeNull();
expect(overlayContainer?.querySelector('.cdk-overlay-backdrop')).toBeNull();
});
});
@@ -40,9 +40,15 @@ export class FormCloudSpinnerService {
const componentRef = this.overlayRef.attach(userProfilePortal);
componentRef.instance.message = event.payload.message;
} else if (event?.payload.showSpinner === false) {
this.overlayRef?.detach();
this.overlayRef = null;
this.disposeOverlay();
}
});
destroyRef.onDestroy(() => this.disposeOverlay());
}
private disposeOverlay(): void {
this.overlayRef?.dispose();
this.overlayRef = null;
}
}