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

fix(sidenav): correctly detect when sidenav align changes. #1758

Merged
merged 6 commits into from
Nov 8, 2016

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Nov 7, 2016

Fixes #1236

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 7, 2016
@mmalerba mmalerba changed the title Snav align fix(slider): correctly detect when sidenav align changes. Nov 7, 2016
value = (value == 'end') ? 'end' : 'start';
if (value != this._align) {
this._align = value;
this.onAlignChanged.emit();
Copy link
Member

Choose a reason for hiding this comment

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

Why not just directly call validateDrawers here instead of going through an observable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is part of MdSidenav, validateDrawers is part of MdSidenavLayout, so I couldn't call it directly.

if (!value) {
this.close();
}
this._valid = value;
Copy link
Member

Choose a reason for hiding this comment

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

I'd do this as

this._valid = coerceBooleanProperty(value);

if (!this._valid) {
  this.close();
}

I generally like to avoid overwriting function arguments.

Can you also add a comment explaining why you want to close the sidenav in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a comment, but I did it this way because once _valid is false toggle (called by close) just returns without doing anything.

@@ -275,48 +313,74 @@ export class MdSidenavLayout implements AfterContentInit {
}
}

/** TODO: internal */
/** @override */
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the @override is necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there something else we can put here to indicate that it's being implemented as part of an interface? The rest of the TODO: internal's we prefixed with an underscore, but we can't do that here.

Copy link
Member

Choose a reason for hiding this comment

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

For lifecycle events it's fine to just leave it- people should just know not to call them.

@jelbourn
Copy link
Member

jelbourn commented Nov 8, 2016

Can you also update the README to mention this invalid state?

@mmalerba
Copy link
Contributor Author

mmalerba commented Nov 8, 2016

Done

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Nov 8, 2016
@jelbourn jelbourn merged commit 5ffdea6 into angular:master Nov 8, 2016
rolandjitsu pushed a commit to rolandjitsu/material2 that referenced this pull request Nov 10, 2016
@mmalerba mmalerba deleted the snav-align branch November 18, 2016 00:34
@gatuteck
Copy link

Hi Angular Team, I have used sidenav component for displaying menu. When I click on the menu item it won't disappear but redirect me to that page and menu is still there. I have used all three modes (side, push, over).
http://home.developmentserver.me/

@jelbourn
Copy link
Member

@gatuteck You can file bug reports here: https://github.com/angular/material2/issues. Be sure to follow the issue template.

Commenting on random pull requests doesn't accomplish anything.

@mmalerba mmalerba changed the title fix(slider): correctly detect when sidenav align changes. fix(sidenav): correctly detect when sidenav align changes. Mar 1, 2017
@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 backdrop problem when changing align dynamically from left to right
4 participants