Skip to content
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

Sidenav closes with Esc #1172

Closed
maghidini opened this issue Jul 4, 2018 · 4 comments
Closed

Sidenav closes with Esc #1172

maghidini opened this issue Jul 4, 2018 · 4 comments

Comments

@maghidini
Copy link

Once you open the sidenav and closes it with Esc, after there is no way to re-open it, since the action LayoutActions.OpenSidenav() hasn't been dispatched. One quick fix is adding attribute disableClose on mat-sidenav element into sidenav.component.ts leaving:
<mat-sidenav [opened]="open" disableClose>

@timdeschryver
Copy link
Member

Hi @maghidini, are you willing to open a PR with your fix? 😄

@manklu
Copy link

manklu commented Jul 12, 2018

The following material sample contains anything needed to capture escape and backdrop click to dispatch the close event.
https://stackblitz.com/angular/nnoxoxrlemx?file=app%2Fsidenav-disable-close-example.html

Altenatively you can listen to the openedChange event.
https://material.angular.io/components/sidenav/api

@mgred
Copy link
Contributor

mgred commented Aug 12, 2018

Hi all,
I took on this bug (hope nobody worked on it in the meanwhile).

The example linked by @manklu looks nice, but cannot be easily applied into the code as far as I can say. This is due to the fact that you need mat-sidenav and mat-sidenav-content to be in one component, as stated here.

I created #1244 which fixed this by applying disableClose as @maghidini already suggested and inserted a manual closing mechanism with (keydown.escape)="sidenav.close()". Also the action CloseSidenav is fired.

mgred added a commit to mgred/platform that referenced this issue Aug 13, 2018
dump/smart component convention, now dispatching the closing
action in the containter component (app.component)
See: ngrx#1172
@maghidini
Copy link
Author

Looks good to me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants