Skip to content

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
@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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I initially just moved it to the right of the boundary. I have made it calculate now offset of the overflown pixels. lemme know if this needs any more correction.

@crisbeto
Copy link
Member

Looks like there's a merge conflicts in the API goldens.

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
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release labels Apr 20, 2025
@crisbeto crisbeto removed the request for review from andrewseguin April 20, 2025 06:37
@crisbeto crisbeto merged commit cf61960 into angular:main Apr 20, 2025
24 of 26 checks passed
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: cdk/drag-drop detected: feature PR contains a feature commit target: major This PR is targeted for the next major release
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