-
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(drawer): infinite loop when two-way opened binding is toggled mid-animation #8872
fix(drawer): infinite loop when two-way opened binding is toggled mid-animation #8872
Conversation
src/lib/sidenav/drawer.ts
Outdated
@@ -195,7 +195,7 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr | |||
_animationState: 'open-instant' | 'open' | 'void' = 'void'; | |||
|
|||
/** Event emitted when the drawer open state is changed. */ | |||
@Output() openedChange: EventEmitter<boolean> = new EventEmitter<boolean>(); | |||
@Output() openedChange: EventEmitter<boolean> = new EventEmitter<boolean>(true); |
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.
...(/* isAsync */ true)
since it kind of looks like initializing open to true
17917a5
to
8ab5de6
Compare
…-animation As of angular@004e0fe the drawer supports a two-way binding on the `opened` property, however because the `openedChange` emits at the end of the animation and two-way bindings invoke their setter which then trigger an animation which in turn invokes `openedChange`, there is the potential for an infinite loop if the user changes the `opened` state mid-animation. These changes avoid the issue by turning the `openedChanged` into an async stream and emitting the current value at the end of the animation, rather than determining the value based on the animation state. Fixes angular#8869.
8ab5de6
to
278e191
Compare
Caretaker note: this might cause some |
…-animation (#8872) As of 004e0fe the drawer supports a two-way binding on the `opened` property, however because the `openedChange` emits at the end of the animation and two-way bindings invoke their setter which then trigger an animation which in turn invokes `openedChange`, there is the potential for an infinite loop if the user changes the `opened` state mid-animation. These changes avoid the issue by turning the `openedChanged` into an async stream and emitting the current value at the end of the animation, rather than determining the value based on the animation state. Fixes #8869.
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. |
As of 004e0fe the drawer supports a two-way binding on the
opened
property, however because theopenedChange
emits at the end of the animation and two-way bindings invoke their setter which then trigger an animation which in turn invokesopenedChange
, there is the potential for an infinite loop if the user changes theopened
state mid-animation. These changes avoid the issue by turning theopenedChanged
into an async stream and emitting the current value at the end of the animation, rather than determining the value based on the animation state.Fixes #8869.