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(dialog): close all dialogs on popstate/hashchange #2742

Merged
merged 1 commit into from
Apr 25, 2017

Conversation

crisbeto
Copy link
Member

Closes all of the open dialogs when the user goes forwards/backwards in history.

Fixes #2601.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 21, 2017
// through it. We loop through all of them and call close without assuming that
// they'll be removed from the list instantaneously.
this._openDialogs[i].close();
if (i > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this check necessary?

i-- should return zero at beginning and the while would not run at all. And i should be always an integer from [0; X] .

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really. I'll remove it.

@jelbourn
Copy link
Member

LGTM

@vicb can you confirm that this is a reasonable thing to do?

// Close all of the dialogs when the user goes forwards/backwards in history or when the
// location hash changes. Note that this usually doesn't include clicking on links (unless
// the user is using the `HashLocationStrategy`).
_location.subscribe(() => this.closeAll());
Copy link

Choose a reason for hiding this comment

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

you probably want to unsubscribe in ngOnDestroy

Copy link
Member Author

@crisbeto crisbeto Jan 23, 2017

Choose a reason for hiding this comment

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

This is inside of a service.

@vicb
Copy link

vicb commented Jan 23, 2017

LGTM with un-subscription + test

@jelbourn
Copy link
Member

Dialog actually isn't a singleton; in apps with lazy-loading, you necessarily have multiple instances of MdDialog, which means that we need to delegate to the ancestor dialog if there is one.

@crisbeto
Copy link
Member Author

Done.

@jelbourn
Copy link
Member

LGTM

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Jan 24, 2017
@kara kara added pr: needs rebase and removed action: merge The PR is ready for merge by the caretaker labels Feb 9, 2017
@kara
Copy link
Contributor

kara commented Feb 9, 2017

@crisbeto Rebase?

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed pr: needs rebase labels Feb 9, 2017
@andrewseguin
Copy link
Contributor

Can you rebase once again :)

@andrewseguin andrewseguin added pr: needs rebase and removed action: merge The PR is ready for merge by the caretaker labels Feb 17, 2017
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed pr: needs rebase labels Feb 17, 2017
@mmalerba mmalerba added pr: needs rebase and removed action: merge The PR is ready for merge by the caretaker labels Feb 22, 2017
@mmalerba
Copy link
Contributor

please rebase

@crisbeto
Copy link
Member Author

Sorry for the delay on this one, I must've missed the notification.

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed pr: needs rebase labels Mar 16, 2017
@mmalerba
Copy link
Contributor

mmalerba commented Mar 17, 2017

There are a number of tests failing in google because there is no provider for Location. Is this something that can be solved by importing somew module in MdDialogModule? or do we just need to make all of these failing tests provide SpyLocation?

@mmalerba
Copy link
Contributor

@vicb Any advice on how to handle that fact that using MdDialog now requires Location to be provided in tests? It would be nice if we didn't force everyone to add it to their tests manually

@jelbourn jelbourn added the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Apr 11, 2017
@crisbeto crisbeto force-pushed the 2601/dialog-pop-state branch 2 times, most recently from 4abed15 to 6811780 Compare April 24, 2017 17:40
@mmalerba
Copy link
Contributor

@crisbeto The way this is currently set up I have to provide SpyLocation in everyone's unit tests to get them to not fail, could you make the Location optional and just skip the close on fwd/back if its not provided?

@mmalerba mmalerba added in progress This issue is currently in progress and removed action: merge The PR is ready for merge by the caretaker labels Apr 25, 2017
Closes all of the open dialogs when the user goes forwards/backwards in history.

Fixes angular#2601.
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed in progress This issue is currently in progress labels Apr 25, 2017
@mmalerba mmalerba removed the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Apr 25, 2017
@mmalerba mmalerba merged commit 85bc3a6 into angular:master Apr 25, 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.

MdDialog does not close when browser's back or forward button clicked
8 participants