Skip to content

docs(drawer): Add additional documentation for disableClose #6750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/sidenav/drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
/** Mode of the drawer; one of 'over', 'push' or 'side'. */
@Input() mode: 'over' | 'push' | 'side' = 'over';

/** Whether the drawer can be closed with the escape key or not. */
/** Whether the drawer can be closed with the escape key or by clicking on the backdrop. */
@Input()
get disableClose(): boolean { return this._disableClose; }
set disableClose(value: boolean) { this._disableClose = coerceBooleanProperty(value); }
Expand Down
12 changes: 12 additions & 0 deletions src/lib/sidenav/sidenav.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,15 @@ html, body, material-app, md-sidenav-container, .my-content {
### FABs inside sidenav
For a sidenav with a FAB (Floating Action Button) or other floating element, the recommended approach is to place the FAB
outside of the scrollable region and absolutely position it.


### Disabling closing of sidenav
By default, sidenav can be closed either by clicking on the backdrop or by pressing <kbd>ESCAPE</kbd>.
The `disableClose` attribute can be set on `md-sidenav` to disable automatic closing when the backdrop
is clicked or <kbd>ESCAPE</kbd> is pressed. To add custom logic on backdrop click, add a `(backdropClick)` listener to
`md-sidenav-container`. For custom <kbd>ESCAPE</kbd> logic, a standard `(keydown)` listener will suffice.
```html
<md-sidenav-container (backdropClick)="customBackdropClickHandler()">
<md-sidenav disableClose (keydown)="customKeydownHandler($event)"></md-sidenav>
</md-sidenav-container>
```