-
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
bug(CdkDrag): CdkDrag stays outside the boundary if it's size change #30325
Comments
Doing this automatically won't be efficient, because we'll have to poll the DOM for changes in the boundary element's position. That being said, we should have an API that will re-align the element to the boundary on demand. |
would something like this work? <div #boundary class="example-boundary">
<div #dragItem="cdkDrag" class="example-box" cdkDragBoundary=".example-boundary" cdkDrag>
I can only be dragged within the dotted container
</div>
</div>
<button mat-button (click)="onResizeClick(boundary, dragItem);">Resize boundary</button> onResizeClick(boundary: HTMLElement, dragItem: CdkDrag) {
boundary.style.width = '220px';
dragItem.reset();
} |
I've tried it as workaround, but the problem with this |
this commit introduces `resetToBoundary` in DragRef which allows user to align DragItem to its boundary on demand if at one point it was at a place where the boundary element used to be and has shrinked causing DragItem to be outside of the boundary box fixes angular#30325
this commit introduces `resetToBoundary` in DragRef which allows user to align DragItem to its boundary on demand if at one point it was at a place where the boundary element used to be and has shrinked causing DragItem to be outside of the boundary box fixes angular#30325
this commit introduces `resetToBoundary` in DragRef which allows user to align DragItem to its boundary on demand if at one point it was at a place where the boundary element used to be and has shrinked causing DragItem to be outside of the boundary box fixes angular#30325
Is this a regression?
The previous version in which this bug was not present was
No response
Description
If the size of the drag boundary changes, the draggable element does not recalculate its position and remains outside the boundary.
Reproduction
StackBlitz link: https://stackblitz.com/edit/l8npyx4z?file=src%2Fexample%2Fcdk-drag-drop-boundary-example.html,src%2Fexample%2Fcdk-drag-drop-boundary-example.ts
Steps to reproduce:
Expected Behavior
The drag element should stay inside the boundary,
Actual Behavior
It stays outside the boundary.
Environment
The text was updated successfully, but these errors were encountered: