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

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

Closed
chintankavathia opened this issue Jul 24, 2024 · 2 comments · Fixed by #30175
Closed
Assignees
Labels
area: cdk/drag-drop P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@chintankavathia
Copy link

chintankavathia commented Jul 24, 2024

Description

CDK Drag and Drop allows to reorder rows within material table however it is not possible to restrict the reordering only using drag handle icon.

Reproduction

StackBlitz link: https://stackblitz.com/edit/vaeujs-yrvig8?file=src%2Fexample%2Fcdk-drag-drop-table-example.html
Steps to reproduce:

  1. Open drag and drop on table rows example from here https://material.angular.io/cdk/drag-drop/examples#cdk-drag-drop-table
  2. Add cdkDragHandle to first cell def mat-icon

Expected Behavior

Row should only be dragged using the icon.

Actual Behavior

Rows can be dragged from anywhere within that row.

Environment

  • Angular: 18.1
  • CDK/Material: 18.1
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS
@chintankavathia chintankavathia added the needs triage This issue needs to be triaged by the team label Jul 24, 2024
@andrewseguin andrewseguin added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: cdk/drag-drop and removed needs triage This issue needs to be triaged by the team labels Jul 24, 2024
@xylplm
Copy link

xylplm commented Dec 4, 2024

hope to fix this bug as soon as possible, as it has a significant impact on the user experience.

@xylplm
Copy link

xylplm commented Dec 6, 2024

@andrewseguin @crisbeto Request experts to improve the progress. This issue has a significant impact on the operation of mobile devices. At present, I have to turn off this function on my mobile phone. I hope it can be repaired as soon as possible. Thank you.

@crisbeto crisbeto self-assigned this Dec 12, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 12, 2024
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 added a commit that referenced this issue Dec 12, 2024
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.

(cherry picked from commit a141c22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/drag-drop P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants