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

docs(cdk\drag-drop): Add table drag drop example #28969

Merged
merged 1 commit into from
May 1, 2024

Conversation

GiftLanga
Copy link
Contributor

Adds an example that shows how to drag and drop table rows Fixes #25168

@angular-robot angular-robot bot added the area: docs Related to the documentation label Apr 26, 2024
@crisbeto crisbeto added the dev-app preview When applied, previews of the dev-app are deployed to Firebase label Apr 27, 2024
@GiftLanga GiftLanga force-pushed the docs/add-drag-drop-table-example branch 2 times, most recently from 94f4ae2 to bb1c375 Compare April 29, 2024 07:45
Copy link

github-actions bot commented Apr 29, 2024

Deployed dev-app for bc612dc to: https://ng-dev-previews-comp--pr-angular-components-28969-dev-80lb1mz4.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

Thank you for the PR, I left a few comments but overall it looks good.

<ng-container matColumnDef="position" sticky>
<mat-header-cell *matHeaderCellDef> No. </mat-header-cell>
<mat-cell *matCellDef="let element">
<mat-icon class="example-drag-cursor" (mousedown)="dragDisabled = false;">reorder</mat-icon>
Copy link
Member

Choose a reason for hiding this comment

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

Why is dragging disabled initially? When I was trying it out, it felt a bit buggy because it wouldn't start dragging the first time. I think that we should just remove the dragDisabled binding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to enable dragging only when the user clicks the drag icon, but I see verry laggy. I'll just remove it.

cursor: move;
}

.cdk-drag-preview {
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a background color to this one? Currently it's transparent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll add it.

Comment on lines 243 to 245
Adding `cdkDropList` on the `mat-table` element and the `cdkDrag` on the `mat-row` element groups the rows into a
reorderable collection. Rows will automatically rearrange as an element moves. You need to
listen to the `cdkDropListDropped` event to update the data model once the user finishes dragging.
Copy link
Member

Choose a reason for hiding this comment

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

This describes how the drag&drop works in general. I think we can just say something about how drag&drop can be integrated into a table.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How does this sound?

"Angular Material provides seamless integration of drag-and-drop functionality into tables, by adding the cdkDropList directive to your mat-table and handling the (cdkDropListDropped) event, you can enable drag-and-drop interactions within your table. This allows users to reorder rows or perform other custom actions with ease."

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good

@devversion devversion removed their request for review April 30, 2024 07:53
@GiftLanga GiftLanga force-pushed the docs/add-drag-drop-table-example branch 2 times, most recently from d79ef43 to bc612dc Compare April 30, 2024 10:22
Adds an example that shows how to drag and drop table rows
Fixes angular#25168
@GiftLanga GiftLanga force-pushed the docs/add-drag-drop-table-example branch from bc612dc to d58b39d Compare April 30, 2024 13:10
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release merge: fix commit message When the PR is merged, rewrites/fixups of the commit messages are needed and removed dev-app preview When applied, previews of the dev-app are deployed to Firebase labels May 1, 2024
@crisbeto crisbeto removed the request for review from andrewseguin May 1, 2024 07:52
@crisbeto crisbeto merged commit 26aa8fa into angular:main May 1, 2024
13 checks passed
crisbeto pushed a commit that referenced this pull request May 1, 2024
Adds an example that shows how to drag and drop table rows

(cherry picked from commit 26aa8fa)
crisbeto pushed a commit that referenced this pull request May 1, 2024
Adds an example that shows how to drag and drop table rows

(cherry picked from commit 26aa8fa)
@GiftLanga GiftLanga deleted the docs/add-drag-drop-table-example branch May 2, 2024 06:29
@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 Jun 2, 2024
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: docs Related to the documentation merge: fix commit message When the PR is merged, rewrites/fixups of the commit messages are needed target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs(cdk/drag-drop): Example for table.
2 participants