Skip to content

refactor(drag-drop): clean up DragRef public API #14654

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
Jan 15, 2019

Conversation

crisbeto
Copy link
Member

Cleans up the API of the DragRef before we can expose it through the public API by making the handle, custom placeholder and custom preview easier to configure.

Note: marking as merge safe, because all of the public API signature changes are to classes that haven't been exposed yet.

@crisbeto crisbeto added pr: merge safe target: patch This PR is targeted for the next patch release labels Dec 27, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 27, 2018
* Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
* @param handle Handle element that should be disabled.
*/
disableHandle(handle: HTMLElement) {
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: I'm not too happy with having to add this method and enableHandle below, since it means having to do this above, however we need them in order to keep backwards compatibility. They allow us to handle the case where the user starts to drag from a disabled handle, in which case the dragging sequence should be interrupted. In the future we can reconsider whether supporting that case is worth it.

@crisbeto crisbeto force-pushed the drag-ref-api-cleanup branch 2 times, most recently from 119499f to 011ba9a Compare December 27, 2018 21:06
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

startWith(this._handles),
// Sync the new handles with the DragRef.
tap((handles: QueryList<CdkDragHandle>) => {
const ownHandles = handles.reduce((accumulator, handle) => {
Copy link
Member

Choose a reason for hiding this comment

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

I would do

const childHandleElements =
   handles.filter(h => h._parentDrag === this).map(h => h.element);

The number of handles will be trivially small

Cleans up the API of the DragRef before we can expose it through the public API by making the handle, custom placeholder and custom preview easier to configure.
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Jan 12, 2019
@crisbeto crisbeto force-pushed the drag-ref-api-cleanup branch from 011ba9a to ff0faf9 Compare January 12, 2019 15:21
@vivian-hu-zz vivian-hu-zz merged commit 0fd6456 into angular:master Jan 15, 2019
s2-abdo pushed a commit to s2-abdo/material2 that referenced this pull request Jan 18, 2019
Cleans up the API of the DragRef before we can expose it through the public API by making the handle, custom placeholder and custom preview easier to configure.
s2-abdo pushed a commit to s2-abdo/material2 that referenced this pull request Jan 18, 2019
Cleans up the API of the DragRef before we can expose it through the public API by making the handle, custom placeholder and custom preview easier to configure.
vivian-hu-zz pushed a commit that referenced this pull request Jan 18, 2019
Cleans up the API of the DragRef before we can expose it through the public API by making the handle, custom placeholder and custom preview easier to configure.
@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 10, 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 target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants