Skip to content

Commit 4f4c48c

Browse files
jwshinjwshintinayuangao
authored andcommitted
docs(drawer): Add additional documentation for disableClose (#6750)
* create event for ESCAPE keydown * revert changes and update doc instead * address comments * minor modification * remove mention of drawer
1 parent 9f2fd47 commit 4f4c48c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/lib/sidenav/drawer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
119119
/** Mode of the drawer; one of 'over', 'push' or 'side'. */
120120
@Input() mode: 'over' | 'push' | 'side' = 'over';
121121

122-
/** Whether the drawer can be closed with the escape key or not. */
122+
/** Whether the drawer can be closed with the escape key or by clicking on the backdrop. */
123123
@Input()
124124
get disableClose(): boolean { return this._disableClose; }
125125
set disableClose(value: boolean) { this._disableClose = coerceBooleanProperty(value); }

src/lib/sidenav/sidenav.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,15 @@ html, body, material-app, md-sidenav-container, .my-content {
7070
### FABs inside sidenav
7171
For a sidenav with a FAB (Floating Action Button) or other floating element, the recommended approach is to place the FAB
7272
outside of the scrollable region and absolutely position it.
73+
74+
75+
### Disabling closing of sidenav
76+
By default, sidenav can be closed either by clicking on the backdrop or by pressing <kbd>ESCAPE</kbd>.
77+
The `disableClose` attribute can be set on `md-sidenav` to disable automatic closing when the backdrop
78+
is clicked or <kbd>ESCAPE</kbd> is pressed. To add custom logic on backdrop click, add a `(backdropClick)` listener to
79+
`md-sidenav-container`. For custom <kbd>ESCAPE</kbd> logic, a standard `(keydown)` listener will suffice.
80+
```html
81+
<md-sidenav-container (backdropClick)="customBackdropClickHandler()">
82+
<md-sidenav disableClose (keydown)="customKeydownHandler($event)"></md-sidenav>
83+
</md-sidenav-container>
84+
```

0 commit comments

Comments
 (0)