You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: cdk-overlay-dark-backdrop is removed before overlay is able to transition out #6071
P4A relatively minor issue that is not relevant to core functionsarea: cdk/overlayneeds: discussionFurther discussion with the team is needed before proceeding
I'm considering this a bug since the default behavior in MdDialog is broken. Currently the overlay detaches once the transition caused by removing cdk-overlay-backdrop-showing has ended. However, the cdk-overlay-dark-backdrop class added by default is also removed before the transition occurs.
What is the expected behavior?
The overlay should smoothly transition the backdrop out.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Latest
Is there anything else we should know?
I'm assuming the removal of custom classes early is intentional so that custom transitions can be defined on the backdrop. The easiest change that is mostly non breaking is to change .cdk-overlay-backdrop to have transition-props: all. However that isn't completely accurate and isn't configurable.
My preference is that the backdropClass specified in the overlay config are always applied up until the dialog is detached, and while the dialog is shown, ${this._state.backdropClass}-showing is toggled on. This allows for full customization of the backdrop before and after the transition.
@jelbourn I've been playing around with this one for a while now and it seems to be a bit more problematic than I thought. There are two things that are preventing the backdrop from animating away correctly:
We remove the class immediately.
We destroy the overlay before the animation has completed.
I set it up to wait for the backdrop to animate away before removing the overlay, but that introduces its own set of issues:
The overlays that use a transparent overlay now "correctly" wait for the backdrop to "animate" away, even though its transparent, it still has a 400ms transition on its opacity. This can be worked around with something like a 1ms transition.
A bunch of tests need to be updated. I did it already and it's not too painful, but there are ~60 of them.
Waiting for the backdrop to go away seems to mess up the closing animations for some components.
@crisbeto if it's that problematic to change, I'd rather leave this for now and revisit it further down the road since I don't see it as being that major of an issue.
I've been playing a bit around with the CDK and made a npm package to help out with this too.
What I've come down to that the detatchBackdrop should really only remove the -showing class and not the backdropClass that you attached in the config.
That way you can easily control the transitions and their durations with CSS on your own classes rather than having it on the base .cdk-overlay-backdroplike it is today, and it's very useful if you have many different backdrop colors (We use both black and white) or special settings.
As stated above the problem is that the class used to apply the color is removed immediately. It's also stated that changing when this is done introduces side effects.
Can't we add another config option that defines if the backdrop should be animated? Wouldn't that resolve side effect issues?
Angular 1's MD Dialog panel is very impressive than this evolving angular 2 material.
Please see this can get this feature(the backdrop animation to body of cdk-overlay-pane) sorted out sooner.
P4A relatively minor issue that is not relevant to core functionsarea: cdk/overlayneeds: discussionFurther discussion with the team is needed before proceeding
Activity
jelbourn commentedon Jul 27, 2017
@crisbeto do you remember why we remove the backdrop class immediately?
crisbeto commentedon Jul 28, 2017
I don't think there's a particular reason for the
backdropClass. The logic can easily be moved to thetransitionendcallback.crisbeto commentedon Jul 28, 2017
@jelbourn I've been playing around with this one for a while now and it seems to be a bit more problematic than I thought. There are two things that are preventing the backdrop from animating away correctly:
I set it up to wait for the backdrop to animate away before removing the overlay, but that introduces its own set of issues:
Here's what I have so far: crisbeto@cb2ce6b
jelbourn commentedon Jul 28, 2017
@crisbeto if it's that problematic to change, I'd rather leave this for now and revisit it further down the road since I don't see it as being that major of an issue.
Epenance commentedon Jan 25, 2018
I've been playing a bit around with the CDK and made a npm package to help out with this too.
What I've come down to that the detatchBackdrop should really only remove the -showing class and not the backdropClass that you attached in the config.
That way you can easily control the transitions and their durations with CSS on your own classes rather than having it on the base
.cdk-overlay-backdroplike it is today, and it's very useful if you have many different backdrop colors (We use both black and white) or special settings.crisbeto commentedon Jan 25, 2018
There's #6627 that should provide some more flexibility.
Epenance commentedon Jan 25, 2018
Was actually following that PR hoping for it to merged some time back last year, but it never seemed to get in :(
Epenance commentedon Jan 25, 2018
Actually managed to fix the visual part of it by doing the following in the css:
Added the background: transparent; and a transition to the background color as well.
skybluerunner commentedon Aug 12, 2018
Here is the hack that I added to my project to get this working.
CSS:
TypeScript:
As stated above the problem is that the class used to apply the color is removed immediately. It's also stated that changing when this is done introduces side effects.
Can't we add another config option that defines if the backdrop should be animated? Wouldn't that resolve side effect issues?
crisbeto commentedon Aug 12, 2018
@thinkingmedia there's #10145 which solves the issue.
sthan001 commentedon Dec 8, 2019
Angular 1's MD Dialog panel is very impressive than this evolving angular 2 material.
Please see this can get this feature(the backdrop animation to body of cdk-overlay-pane) sorted out sooner.
angular-automatic-lock-bot commentedon Dec 13, 2020
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.