Skip to content

Commit 906d3c0

Browse files
Philipp Guerrero Menganayggg
authored andcommitted
fix(toastr): move toastr overlay in front of other overlays (#2078)
1 parent 1d52a20 commit 906d3c0

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/framework/theme/components/toastr/_toast.component.theme.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,7 @@
6363
}
6464
}
6565
}
66+
.toastr-overlay-container {
67+
z-index: 1041;
68+
}
6669
}

src/framework/theme/components/toastr/toastr.service.spec.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@ describe('toastr-component', () => {
4545
fixture = TestBed.createComponent(NbToastrTestComponent);
4646
}));
4747

48+
it('should add \'toastr-overlay-container\' class to overlay', () => {
49+
fixture.debugElement.componentInstance.showToast('toast-test-class');
50+
fixture.detectChanges();
51+
expect(fixture.nativeElement.querySelector('.cdk-global-overlay-wrapper').classList)
52+
.toContain('toastr-overlay-container');
53+
});
54+
4855
it('should set class if provided', () => {
4956
fixture.debugElement.componentInstance.showToast('toast-test-class');
5057
fixture.detectChanges();
5158
expect(fixture.nativeElement.querySelector('.toast-test-class')).toBeTruthy();
52-
})
59+
});
5360
});
5461

5562
describe('toastr-service', () => {
@@ -188,6 +195,11 @@ describe('toastr-container-registry', () => {
188195
}
189196
},
190197
dispose() {},
198+
hostElement: {
199+
classList: {
200+
add() {},
201+
},
202+
},
191203
};
192204

193205
overlayStub = {

src/framework/theme/components/toastr/toastr.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,18 @@ export class NbToastrContainerRegistry {
171171
protected createContainer(position: NbGlobalLogicalPosition): NbToastrOverlayWithContainer {
172172
const positionStrategy = this.positionBuilder.global().position(position);
173173
const ref = this.overlay.create({ positionStrategy });
174+
this.addClassToOverlayHost(ref);
174175
const containerRef = ref.attach(new NbComponentPortal(NbToastrContainerComponent, null, null, this.cfr));
175176
return {
176177
overlayRef: ref,
177178
toastrContainer: new NbToastContainer(position, containerRef, this.positionHelper),
178179
};
179180
}
180181

182+
protected addClassToOverlayHost(overlayRef: NbOverlayRef) {
183+
overlayRef.hostElement.classList.add('toastr-overlay-container');
184+
}
185+
181186
protected existsInDom(toastContainer: NbToastContainer): boolean {
182187
return this.document.body.contains(toastContainer.nativeElement);
183188
}

0 commit comments

Comments
 (0)