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

feat(sidenav): add disableClose option #2501

Merged
merged 2 commits into from
Jan 13, 2017

Conversation

devversion
Copy link
Member

@devversion devversion commented Jan 2, 2017

  • Adds an attribute to the md-sidenav component, which allows developers to disable the closing behavior (e.g escape closing)

    Backdrop stays separate because you can disable it by using the mode attribute.

Closes #2462

* Adds an attribute to the `md-sidenav` component, which allows developers to disable the closing behavior (e.g escape closing)
  Backdrop stays separate because you can disable it by using the `mode` attribute.

Closes angular#2462
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 2, 2017
@jelbourn jelbourn requested review from mmalerba and removed request for jelbourn and andrewseguin January 3, 2017 17:14
@mmalerba
Copy link
Contributor

mmalerba commented Jan 4, 2017

@jelbourn I still like the idea of escapeAction and backdropAction that have values of "none", "close", or a callback function that can be used to implement custom behavior. I remember you being opposed to this when I brought it up last time, but can you remind me why? It seems like a more flexible solution to me.

@jelbourn
Copy link
Member

jelbourn commented Jan 4, 2017

@mmalerba I mainly was put off by the "provide a callback" API style, since we don't do that anywhere else in the library. So rather than having escapeAction plus backdropAction, my preference would be for something like disableClose plus backdropClick Output (or the user setting up their own escape keydown handler).

@mmalerba
Copy link
Contributor

mmalerba commented Jan 4, 2017

Couldn't we just start using this pattern here and elsewhere where it seems appropriate? The API seems clunky otherwise. You need disableCloseOnEscape, disableCloseOnBackdropClick, backdropClick, and escapePressed in order to give users the same amount of control. I think in these cases where the user wants to be able to stop the default action and supply their own the callback style API really makes more sense.

@devversion
Copy link
Member Author

@mmalerba @jelbourn How should we proceed with this PR now?

@mmalerba
Copy link
Contributor

I think I'm outnumbered/outranked on this one, go ahead and do what Jeremy is suggesting

@mmalerba mmalerba closed this Jan 12, 2017
@mmalerba mmalerba reopened this Jan 12, 2017
@mmalerba
Copy link
Contributor

sorry didn't mean to close

@Input()
get disableClose(): boolean { return this._disableClose; }
set disableClose(value: boolean) { this._disableClose = coerceBooleanProperty(value); }
private _disableClose: boolean = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disableClose should also prevent close from backdrop clicks.

While you're doing this, can you also change the @Output to backdropClick? Looks like we missed it when getting rid of dash-case stuff.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jelbourn Made the changes you requested.

@jelbourn
Copy link
Member

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Jan 13, 2017
@tinayuangao tinayuangao merged commit 52ade97 into angular:master Jan 13, 2017
@devversion devversion deleted the feat/sidenav-disable-close branch January 13, 2017 22:57
@@ -414,7 +462,7 @@ class SidenavContainerTwoSidenavTestApp { }
/** Test component that contains an MdSidenavContainer and one MdSidenav. */
@Component({
template: `
<md-sidenav-container (backdrop-clicked)="backdropClicked()">
<md-sidenav-container (backdropClick)="backdropClicked()">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxime1992 The solution to our problem : backdropClick

@christophechevalier
Copy link

christophechevalier commented Feb 3, 2017

Hi @jelbourn @mmalerba

I think the documentation is not up to date on the Event emitted when the sidenav backdrop is clicked.
https://material.angular.io/components/component/sidenav

selection_040

Now, for use event of backdrop-clicked, it's backdropClick as I see.
https://github.com/angular/material2/pull/2501/files

We don't have any hook if user click on escape.
Do you manage that case ?

🚀 @maxime1992

@evanjmg
Copy link

evanjmg commented Feb 27, 2017

There's no class in the html added to indicate that the container is disabled on disable close. This is important for ui tweaks (psuedo selectors - X in the corner ) to tell the user whether they can close the modal or not via outside click.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sidenav disappears when escape is pressed
7 participants