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(overlay): detach method returns undefined #7449

Merged
merged 1 commit into from
Oct 3, 2017

Conversation

devversion
Copy link
Member

@devversion devversion commented Sep 30, 2017

Currently the JSDoc of the detach method describes that the method returns a Promise if the detaching is done. This is not the case and just undefined is being returned because every PortalHost implementation inside of the CDK is synchronously detaching the view.

In the future it might be useful to change this method back to a Promise in favor of animations, but for now it doesn't make sense return a Promise because the attach method is also synchronous.

Fixes #7408

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 30, 2017
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

This needs a breaking change message in the unlikely event that somebody was using this.

*/
detach(): Promise<any> {
/** Detaches an overlay from a portal. */
detach(): void {
Copy link
Member

Choose a reason for hiding this comment

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

Change the PortalHost signature as well?

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 sure about this. I thought that the PortalHost can still have the type in case someone wants to implement his own PortalHost.

Copy link
Member

Choose a reason for hiding this comment

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

But since you're removing the return value from the OverlayRef, it means that even if they did, they wouldn't be able to use it with our overlays anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Portals don't have to be used specifically with overlays.

Copy link
Member

Choose a reason for hiding this comment

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

They don't but that's the primary use case and it's something that we'll end up not supporting. Since the initial goal of the PR was to get rid of the Promise signature, consider re-adding the return and setting the return value to any?

Copy link
Member Author

Choose a reason for hiding this comment

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

That would work too. In that case we would have a very unclear method signature and the return value would be for now always undefined.

Since overlays always seem to use the DomPortalHost which seems to return nothing on detach I thought we can be clear with this signature here.

I'm fine switching to any though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated as discussed on Slack.

Currently the JSDoc of the `detach` method describes that the method returns a Promise if the detaching is done. This is not the case and just `undefined` is being returned because every `PortalHost` implementation inside of the CDK is synchronously detaching the view.

In the future it might be useful to change this method back to a `Promise` in favor of animations, but for now it doesn't make sense return a `Promise` because the `attach` method is also synchronous.

Fixes angular#7408
@devversion devversion force-pushed the fix/overlay-detach-promise-null branch from 0fa6ed4 to e4a5ac8 Compare October 1, 2017 08:50
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

@crisbeto crisbeto added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Oct 1, 2017
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@kara kara merged commit 0584cdf into angular:master Oct 3, 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 7, 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.

An undefined value is returned by OverlayRef.detach()
5 participants