-
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(drag-drop): error if drag item is destroyed before the zone has stabilized #13978
fix(drag-drop): error if drag item is destroyed before the zone has stabilized #13978
Conversation
We initialize the `rootElement` in an `NgZone.onStable` callback, however if the zone doesn't stabilize before the `cdkDrag` is destroyed, we'll throw an error because there is no `rootElement`. These changes add an extra check to ensure that we don't throw.
rootElement.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions); | ||
toggleNativeDragInteractions(rootElement , false); | ||
}); | ||
this._rootElementInitSubscription = this._ngZone.onStable.asObservable() |
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.
Could to use takeUntil
with _destroyed
subject here?
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.
I could, but then we'd have the _destroyed
only for this one case.
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
I don't feel super strongly, but do generally prefer the takeUntil
approach even if it's only being used once.
…13978) We initialize the `rootElement` in an `NgZone.onStable` callback, however if the zone doesn't stabilize before the `cdkDrag` is destroyed, we'll throw an error because there is no `rootElement`. These changes add an extra check to ensure that we don't throw.
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. |
We initialize the
rootElement
in anNgZone.onStable
callback, however if the zone doesn't stabilize before thecdkDrag
is destroyed, we'll throw an error because there is norootElement
. These changes add an extra check to ensure that we don't throw.