mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
AAE-33340 Async Form Enrichment - Spinner doesnt hide on process completion (#10749)
This commit is contained in:
parent
abaf7df9c6
commit
142c6ae754
@ -83,4 +83,16 @@ describe('FormCloudSpinnerService', () => {
|
||||
hasSpinner = await rootLoader.hasHarness(MatProgressSpinnerHarness);
|
||||
expect(hasSpinner).toBeFalse();
|
||||
});
|
||||
|
||||
it('should show only one spinner at time', async () => {
|
||||
spinnerService.initSpinnerHandling(destroyRef);
|
||||
formService.toggleFormSpinner.next(showSpinnerEvent);
|
||||
const otherShowSpinnerEvent = new FormSpinnerEvent('toggle-spinner', { showSpinner: true, message: 'ANOTHER' });
|
||||
formService.toggleFormSpinner.next(otherShowSpinnerEvent);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
const spinners = await rootLoader.getAllHarnesses(MatProgressSpinnerHarness);
|
||||
expect(spinners.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
@ -27,11 +27,11 @@ export class FormCloudSpinnerService {
|
||||
private formService = inject(FormService);
|
||||
private overlay = inject(Overlay);
|
||||
|
||||
private overlayRef?: OverlayRef;
|
||||
private overlayRef?: OverlayRef = null;
|
||||
|
||||
initSpinnerHandling(destroyRef: DestroyRef): void {
|
||||
this.formService.toggleFormSpinner.pipe(takeUntilDestroyed(destroyRef)).subscribe((event: FormSpinnerEvent) => {
|
||||
if (event?.payload.showSpinner) {
|
||||
if (event?.payload.showSpinner && this.overlayRef === null) {
|
||||
this.overlayRef = this.overlay.create({
|
||||
hasBackdrop: true
|
||||
});
|
||||
@ -41,6 +41,7 @@ export class FormCloudSpinnerService {
|
||||
componentRef.instance.message = event.payload.message;
|
||||
} else if (event?.payload.showSpinner === false) {
|
||||
this.overlayRef?.detach();
|
||||
this.overlayRef = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user