Skip to content

Conversation

@crisbeto
Copy link
Member

Currently the cdkDragHandle directive registers itself with the parent by resolving it through DI. This doesn't work if the directive is declared in a separate embedded view (e.g. ng-template) that is then projected into the draggable element. It can be problematic when adding dragging support to a mat-table.

These changes fix the issue by falling back to resolving the draggable directive through the DOM.

Fixes #29475.

Switches to tracking the registered directive nodes in the registry instead of a private static field. This allows us to reuse the logic in the handles.
Currently the `cdkDragHandle` directive registers itself with the parent by resolving it through DI. This doesn't work if the directive is declared in a separate embedded view (e.g. `ng-template`) that is then projected into the draggable element. It can be problematic when adding dragging support to a `mat-table`.

These changes fix the issue by falling back to resolving the draggable directive through the DOM.

Fixes angular#29475.
@crisbeto crisbeto added target: patch This PR is targeted for the next patch release merge: preserve commits When the PR is merged, a rebase and merge should be performed labels Dec 12, 2024
@crisbeto crisbeto requested a review from a team as a code owner December 12, 2024 08:45
@crisbeto crisbeto requested review from andrewseguin and mmalerba and removed request for a team December 12, 2024 08:45
@xylplm
Copy link

xylplm commented Dec 12, 2024

Thank you very much to the technical experts for solving the problem

@crisbeto crisbeto removed the request for review from mmalerba December 12, 2024 20:58
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Dec 12, 2024
@crisbeto crisbeto merged commit a141c22 into angular:main Dec 12, 2024
24 of 27 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 Jan 12, 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 merge: preserve commits When the PR is merged, a rebase and merge should be performed target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(cdk/drag-drop): not possible to use custom drag handle with mat table rows

3 participants