Skip to content

Commit f9c750a

Browse files
committed
fix(backdrop): Disable backdrop's background-color if backdrop is disabled
1 parent 8116ed5 commit f9c750a

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/lib/components/ng-http-loader.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*ngIf="isVisible$ | async"
33
[class.backdrop]="backdrop"
44
[style.opacity]="opacity"
5-
[style.backgroundColor]="backdropBackgroundColor">
5+
[ngStyle]="{'background-color': backdrop ? backdropBackgroundColor : 'transparent'}">
66

77
<ng-container *ngComponentOutlet="entryComponent"></ng-container>
88

src/test/components/ng-http-loader.component.spec.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ describe('NgHttpLoaderComponent', () => {
799799
expect(element.style.opacity).toBe(`0${component.opacity}`);
800800
});
801801

802-
it('should have a default backdrop background color', () => {
802+
it('should have a default backdrop background color if backdrop is true', () => {
803803
component.isVisible$ = of(true);
804804
fixture.detectChanges();
805805

@@ -811,7 +811,7 @@ describe('NgHttpLoaderComponent', () => {
811811
expect(element.style.backgroundColor).toBe('rgb(241, 241, 241)');
812812
});
813813

814-
it('should be possible to override backdrop background color', () => {
814+
it('should be possible to override backdrop background color when backdrop is true', () => {
815815
component.isVisible$ = of(true);
816816
component.backdropBackgroundColor = '#777777';
817817
fixture.detectChanges();
@@ -823,4 +823,17 @@ describe('NgHttpLoaderComponent', () => {
823823

824824
expect(element.style.backgroundColor).toBe('rgb(119, 119, 119)');
825825
});
826+
827+
it('should not have a transparent backdrop background color if backdrop is false', () => {
828+
component.isVisible$ = of(true);
829+
component.backdrop = false;
830+
fixture.detectChanges();
831+
832+
const element: HTMLElement = fixture
833+
.debugElement
834+
.query(By.css('#spinner'))
835+
.nativeElement;
836+
837+
expect(element.style.backgroundColor).toBe('transparent');
838+
});
826839
});

0 commit comments

Comments
 (0)