Skip to content

Commit a6240b6

Browse files
committed
fix(sidenav): fullscreen sidenavs should not scroll
1 parent ca5339b commit a6240b6

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

src/components/sidenav/sidenav.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ $md-sidenav-push-background-color: md-color($md-background, dialog) !default;
6464
// TODO(hansl): Update this with a more robust solution.
6565
&[fullscreen] {
6666
@include md-sidenav-fullscreen();
67+
68+
&.md-sidenav-opened {
69+
overflow: hidden;
70+
}
6771
}
6872

6973
// Need this to take up space in the layout.
@@ -109,6 +113,9 @@ $md-sidenav-push-background-color: md-color($md-background, dialog) !default;
109113
z-index: 3;
110114
min-width: 5%;
111115

116+
// TODO(kara): revisit scrolling behavior for sidenavs
117+
overflow-y: auto;
118+
112119
background-color: $md-sidenav-background-color;
113120

114121
@include md-sidenav-transition(0, -100%);

src/components/sidenav/sidenav.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class MdSidenav {
4949
@Input() mode: 'over' | 'push' | 'side' = 'over';
5050

5151
/** Whether the sidenav is opened. */
52-
@Input('opened') private _opened: boolean;
52+
@Input('opened') private _opened: boolean = false;
5353

5454
/** Event emitted when the sidenav is being opened. Use this to synchronize animations. */
5555
@Output('open-start') onOpenStart = new EventEmitter<void>();
@@ -318,9 +318,13 @@ export class MdSidenavLayout implements AfterContentInit {
318318
}
319319
}
320320

321-
private _isShowingBackdrop() {
322-
return (this._start != null && this._start.mode != 'side' && this._start.opened)
323-
|| (this._end != null && this._end.mode != 'side' && this._end.opened);
321+
private _isShowingBackdrop(): boolean {
322+
return (this._isSidenavOpen(this._start) && this._start.mode != 'side')
323+
|| (this._isSidenavOpen(this._end) && this._end.mode != 'side');
324+
}
325+
326+
private _isSidenavOpen(side: MdSidenav): boolean {
327+
return side != null && side.opened;
324328
}
325329

326330
/**
@@ -330,10 +334,7 @@ export class MdSidenavLayout implements AfterContentInit {
330334
* @private
331335
*/
332336
private _getSidenavEffectiveWidth(sidenav: MdSidenav, mode: string): number {
333-
if (sidenav != null && sidenav.mode == mode && sidenav.opened) {
334-
return sidenav._width;
335-
}
336-
return 0;
337+
return (this._isSidenavOpen(sidenav) && sidenav.mode == mode) ? sidenav._width : 0;
337338
}
338339

339340
private _getMarginLeft() {
@@ -351,6 +352,10 @@ export class MdSidenavLayout implements AfterContentInit {
351352
private _getPositionRight() {
352353
return this._getSidenavEffectiveWidth(this._right, 'push');
353354
}
355+
356+
@HostBinding('class.md-sidenav-opened') private get _isOpened() {
357+
return this._isShowingBackdrop();
358+
}
354359
}
355360

356361

src/demo-app/demo-app.scss

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
}
1010

1111
md-sidenav {
12-
width: 15%;
12+
min-width: 15%;
1313

1414
[md-button] {
1515
width: 100%;
16-
position: absolute;
16+
position: relative;
1717
bottom: 0;
18-
margin-bottom: 24px;
18+
margin: 24px 0;
1919
}
2020
}
2121

@@ -39,5 +39,4 @@
3939
h1 {
4040
font-size: 20px;
4141
}
42-
}
43-
42+
}

0 commit comments

Comments
 (0)