Skip to content

feat(drag-drop): convert cdk-drop into a directive #13441

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

Merged
merged 1 commit into from
Oct 8, 2018

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Oct 5, 2018

Converts cdk-drop into a directive and moves the handful of structural styles into JS.

Fixes #13341.

@crisbeto crisbeto added P2 The issue is important to a large percentage of users, with a workaround target: major This PR is targeted for the next major release labels Oct 5, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 5, 2018
@crisbeto
Copy link
Member Author

crisbeto commented Oct 5, 2018

Marking as P2, because it's a breaking change that would be good to get in before the API is considered stable. @jelbourn since this a breaking in an API that isn't stable yet, I haven't included a backwards-compatibility layer. I can do one if necessary, since we also just entered into RC.

@@ -155,25 +155,15 @@ describe('DragDropRegistry', () => {
expect(dispatchTouchEvent(document, 'touchmove').defaultPrevented).toBe(true);
});

it('should disable the native interactions on the body while dragging', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

I've dropped this test and I haven't added new ones for the other elements that need to get these styles at runtime, because not all of the properties that are added are supported on the browsers that we test against, which will lead to flakes.

@@ -1,15 +1,27 @@
<div class="container">
<h2>To do</h2>

<cdk-drop #todoList [data]="todo" [connectedTo]="doneList" class="list" (dropped)="drop($event)">
<div
cdkDrop
Copy link
Member

@devversion devversion Oct 5, 2018

Choose a reason for hiding this comment

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

Should this be indented by four spaces? It feels odd that the attributes align with the child element.

See: https://google.github.io/styleguide/htmlcssguide.html#HTML_Line-Wrapping

I just see that other schematic components use that formatting as well. I'll switch them to 4 fours spaces in an upcoming PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure about that. Should we be matching the indentation to other components in the repo or the Google guidelines?

Copy link
Member

@devversion devversion Oct 5, 2018

Choose a reason for hiding this comment

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

I don't think it matters for the other components. It just would be good if the components that will be generated by the schematics, are consistent and easy to understand.

And since this change now wraps the HTML attributes, it would be good to change it while being at it. I didn't have a chance to update the other components. The drag-drop schematic was fine because we didn't need to wrap before this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

Converts `cdk-drop` into a directive and moves the handful of structural styles into JS.

Fixes angular#13341.
@crisbeto crisbeto force-pushed the 13341/drop-directive branch from a12abbb to 475dc21 Compare October 5, 2018 10:10
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Oct 5, 2018
@vivian-hu-zz vivian-hu-zz added the merge: fix commit message When the PR is merged, rewrites/fixups of the commit messages are needed label Oct 5, 2018
@vivian-hu-zz vivian-hu-zz merged commit f3555f1 into angular:master Oct 8, 2018

/**
* Function that is used to determine whether an item
* is allowed to be moved into a drop container.
*/
@Input() enterPredicate: (drag?: CdkDrag, drop?: CdkDrop) => boolean = () => true;
@Input('cdkDropEnterPredication')
Copy link

Choose a reason for hiding this comment

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

Why is it renamed from predicate to predication?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question, it's a typo. I'll sort it out.

roboshoes pushed a commit to roboshoes/material2 that referenced this pull request Oct 23, 2018
Converts `cdk-drop` into a directive and moves the handful of structural styles into JS.

Fixes angular#13341.
@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 Sep 9, 2019
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 cla: yes PR author has agreed to Google's Contributor License Agreement merge: fix commit message When the PR is merged, rewrites/fixups of the commit messages are needed P2 The issue is important to a large percentage of users, with a workaround target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CdkDrop should be a Directive rather than a Component
6 participants