Skip to content
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

feat(cdk/drag-drop): introduce resetToBoundary #30436

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

naaajii
Copy link
Contributor

@naaajii naaajii commented Feb 2, 2025

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 #30325

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: cdk/drag-drop labels Feb 2, 2025
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
@naaajii naaajii marked this pull request as ready for review February 2, 2025 19:38
@naaajii naaajii requested a review from a team as a code owner February 2, 2025 19:38
@naaajii naaajii requested review from mmalerba and andrewseguin and removed request for a team February 2, 2025 19:38
@mmalerba mmalerba requested review from crisbeto and removed request for mmalerba February 11, 2025 22:15
resetToBoundary(): void {
// can be null if the drag item was never dragged.
if (this._boundaryElement) {
let x = this._boundaryElement.offsetWidth - this._rootElement.offsetWidth,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow why we need the offset here, it seems like it just gets moved all the way to the right of the boundary. I think we should check if the element is outside the boundary and move it by the amount of overflow pixels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/drag-drop detected: feature PR contains a feature commit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(CdkDrag): CdkDrag stays outside the boundary if it's size change
2 participants