-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(drag-drop): detect changes on custom preview/placeholder before measuring #18698
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): detect changes on custom preview/placeholder before measuring #18698
Conversation
…easuring When a custom preview/placeholder is created, its dimensions are measured so that they can be used while sorting. The problem is that we weren't detecting changes after creation which can cause the dimensions to be incorrect, if they change based on a data binding. These changes check for changes after inserting the embedded view. Fixes angular#18622.
@@ -884,6 +884,7 @@ export class DragRef<T = any> { | |||
if (previewTemplate) { | |||
const viewRef = previewConfig!.viewContainer.createEmbeddedView(previewTemplate, | |||
previewConfig!.context); | |||
viewRef.detectChanges(); |
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.
Rather than directly calling detectChanges
, couldn't we instead defer measuring until Angular completes the change detection it needs to do 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.
Almost none of the drag&drop events trigger change detection so we can't really depend on it since it can happen at any time for other reason. This only detects on a small chunk of the tree 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.
LGTM
…easuring (#18698) When a custom preview/placeholder is created, its dimensions are measured so that they can be used while sorting. The problem is that we weren't detecting changes after creation which can cause the dimensions to be incorrect, if they change based on a data binding. These changes check for changes after inserting the embedded view. Fixes #18622. (cherry picked from commit e87de13)
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. |
When a custom preview/placeholder is created, its dimensions are measured so that they can be used while sorting. The problem is that we weren't detecting changes after creation which can cause the dimensions to be incorrect, if they change based on a data binding. These changes check for changes after inserting the embedded view.
Fixes #18622.