Skip to content

Commit

Permalink
fix(example): close side nav when escape key is pressed (#1244)
Browse files Browse the repository at this point in the history
Closes #1172
  • Loading branch information
mgred authored and brandonroberts committed Aug 16, 2018
1 parent 0c26a95 commit b3fc5dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions example-app/app/core/components/sidenav.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component, Input } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';

@Component({
selector: 'bc-sidenav',
template: `
<mat-sidenav [opened]="open">
<mat-sidenav #sidenav [opened]="open" (keydown.escape)="sidenav.close()" (closedStart)="closeMenu.emit()" disableClose>
<mat-nav-list>
<ng-content></ng-content>
</mat-nav-list>
Expand All @@ -19,4 +19,5 @@ import { Component, Input } from '@angular/core';
})
export class SidenavComponent {
@Input() open = false;
@Output() closeMenu = new EventEmitter();
}
2 changes: 1 addition & 1 deletion example-app/app/core/containers/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as LayoutActions from '../actions/layout.actions';
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<bc-layout>
<bc-sidenav [open]="showSidenav$ | async">
<bc-sidenav [open]="showSidenav$ | async" (closeMenu)="closeSidenav()">
<bc-nav-item (navigate)="closeSidenav()" *ngIf="loggedIn$ | async" routerLink="/" icon="book" hint="View your book collection">
My Collection
</bc-nav-item>
Expand Down

0 comments on commit b3fc5dd

Please sign in to comment.