Skip to content

Commit 9d3d95f

Browse files
crisbetojelbourn
authored andcommitted
fix(sidenav): not positioning correctly in rtl (#12741)
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 5d1643a commit 9d3d95f

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
@@ -162,6 +162,17 @@ $mat-drawer-over-drawer-z-index: 4;
162162
}
163163
}
164164

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

src/lib/sidenav/drawer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class MatDrawerContent extends CdkScrollable implements AfterContentInit
103103
moduleId: module.id,
104104
selector: 'mat-drawer',
105105
exportAs: 'matDrawer',
106-
template: '<ng-content></ng-content>',
106+
templateUrl: 'drawer.html',
107107
animations: [matDrawerAnimations.transformDrawer],
108108
host: {
109109
'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)