Skip to content

Commit 34193cc

Browse files
authored
fix(cdk): fix scroll blocker for custom withScroll mode (#1364)
Closes #1158, Closes #1259
1 parent 788a6d4 commit 34193cc

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/framework/theme/components/cdk/overlay/_overlay.theme.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@
99
z-index: 1040;
1010
}
1111
}
12+
13+
/**
14+
* In case when Nebular Layout custom scroll `withScroll` mode is enabled
15+
* we need to disable default CDK scroll blocker (@link NbBlockScrollStrategyAdapter) on HTML element
16+
* so that it won't add additional positioning.
17+
*/
18+
.nb-global-scrollblock {
19+
position: static;
20+
width: auto;
21+
overflow: hidden;
22+
}

src/framework/theme/components/layout/layout.component.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,21 @@ export class NbLayoutComponent implements AfterViewInit, OnDestroy {
443443
filter(() => this.withScrollValue),
444444
)
445445
.subscribe((scrollable: boolean) => {
446+
const root = this.document.documentElement;
447+
const scrollBlockClass = 'nb-global-scrollblock';
448+
446449
this.overlayScrollBlock = !scrollable;
450+
451+
/**
452+
* In case when Nebular Layout custom scroll `withScroll` mode is enabled
453+
* we need to disable default CDK scroll blocker (@link NbBlockScrollStrategyAdapter) on HTML element
454+
* so that it won't add additional positioning.
455+
*/
456+
if (!scrollable) {
457+
this.renderer.addClass(root, scrollBlockClass);
458+
} else {
459+
this.renderer.removeClass(root, scrollBlockClass);
460+
}
447461
});
448462

449463
if (isPlatformBrowser(this.platformId)) {

0 commit comments

Comments
 (0)