-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix(overlay): detach method returns undefined #7449
Conversation
There was a problem hiding this 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.
src/cdk/overlay/overlay-ref.ts
Outdated
*/ | ||
detach(): Promise<any> { | ||
/** Detaches an overlay from a portal. */ | ||
detach(): void { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
0fa6ed4
to
e4a5ac8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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 justundefined
is being returned because everyPortalHost
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 aPromise
because theattach
method is also synchronous.Fixes #7408