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): add mixed orientation support #29216

Merged
merged 4 commits into from
Jun 12, 2024

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Jun 8, 2024

Currently the drop list sorts items by moving them using a transform which keeps the DOM stable and allows for the sorting to be animated, but has the drawback of only allowing sorting in one direction.

These changes implement a new DropListSortStrategy that allows sorting of lists that can wrap by moving the DOM nodes around directly, rather than via a transform. It has the caveat that it can't animate the sorting action.

The new strategy can be enabled by setting cdkDropListOrientation="mixed".

Fixes #13372.

crisbeto added 3 commits June 8, 2024 12:46
Fixes some test cases that don't behave like a user would do, like hovering over an item that is out of the screen. They worked because currently the drag&drop is almost purely coordinate-based, but that won't be the case with the `mixed` orientation.

Also fixes some concatenated test names that were difficult to search for.
Reduces the amount of information that needs to be passed in for the shared drag&drop tests.
Simplifies the interface for sort strategies to avoid the unnecessary generics that were put in place to avoid circular imports.
@crisbeto crisbeto added target: minor This PR is targeted for the next minor release merge: preserve commits When the PR is merged, a rebase and merge should be performed labels Jun 8, 2024
@crisbeto crisbeto requested a review from a team as a code owner June 8, 2024 10:47
@crisbeto crisbeto requested review from amysorto and wagnermaciel and removed request for a team June 8, 2024 10:47
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Jun 8, 2024
@crisbeto crisbeto requested review from mmalerba and andrewseguin June 8, 2024 10:47
import {createComponent, dragElementViaMouse} from './test-utils.spec';

describe('mixed drop list', () => {
defineCommonDropListTests({
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that we don't have that many tests here, because we reuse the ~190 tests from the existing drop list. We add some more below to ensure that sorting works properly on mixed lists as well.

Currently the drop list sorts items by moving them using a `transform` which keeps the DOM stable and allows for the sorting to be animated, but has the drawback of only allowing sorting in one direction.

These changes implement a new `DropListSortStrategy` that allows sorting of lists that can wrap by moving the DOM nodes around directly, rather than via a `transform`. It has the caveat that it can't animate the sorting action.

The new strategy can be enabled by setting `cdkDropListOrientation="mixed"`.

Fixes angular#13372.
@crisbeto crisbeto force-pushed the mixed-orientation-test branch from 19ebd54 to c0b5c3f Compare June 10, 2024 08:22
@crisbeto crisbeto added the dev-app preview When applied, previews of the dev-app are deployed to Firebase label Jun 10, 2024
Copy link

Deployed dev-app for c0b5c3f to: https://ng-dev-previews-comp--pr-angular-components-29216-dev-tnw1ojix.web.app

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

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Jun 12, 2024
@crisbeto crisbeto merged commit 0bc6583 into angular:main Jun 12, 2024
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 Jul 13, 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 detected: feature PR contains a feature commit dev-app preview When applied, previews of the dev-app are deployed to Firebase merge: preserve commits When the PR is merged, a rebase and merge should be performed target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drag Drop Sortable, mixed orientation support
2 participants