Skip to content

Commit 0f83c18

Browse files
committed
fix(sidenav): not positioning correctly in rtl
Adds a workaround for a Chrome issue where the sidenav content is partially cut off when `dir='rtl'` is set on the `body` or `html` nodes.
1 parent b9651df commit 0f83c18

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/lib/sidenav/drawer.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="mat-drawer-inner-container">
2+
<ng-content></ng-content>
3+
</div>

src/lib/sidenav/drawer.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,17 @@ $mat-drawer-over-drawer-z-index: 4;
155155
}
156156
}
157157

158+
// Note that this div isn't strictly necessary on all browsers, however we need it in
159+
// order to avoid a layout issue in Chrome. The issue is that in RTL mode the browser doesn't
160+
// account for the sidenav's scrollbar while positioning, which ends up pushing it partially
161+
// out of the screen. We work around the issue by having the scrollbar be on this inner container.
162+
.mat-drawer-inner-container {
163+
width: 100%;
164+
height: 100%;
165+
overflow: auto;
166+
-webkit-overflow-scrolling: touch;
167+
}
168+
158169
.mat-sidenav-fixed {
159170
position: fixed;
160171
}

src/lib/sidenav/drawer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class MatDrawerContent extends CdkScrollable implements AfterContentInit
100100
moduleId: module.id,
101101
selector: 'mat-drawer',
102102
exportAs: 'matDrawer',
103-
template: '<ng-content></ng-content>',
103+
templateUrl: 'drawer.html',
104104
animations: [matDrawerAnimations.transformDrawer],
105105
host: {
106106
'class': 'mat-drawer',

src/lib/sidenav/sidenav.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class MatSidenavContent extends MatDrawerContent {
5454
moduleId: module.id,
5555
selector: 'mat-sidenav',
5656
exportAs: 'matSidenav',
57-
template: '<ng-content></ng-content>',
57+
templateUrl: 'drawer.html',
5858
animations: [matDrawerAnimations.transformDrawer],
5959
host: {
6060
'class': 'mat-drawer mat-sidenav',

0 commit comments

Comments
 (0)