Skip to content

fix(drag-drop): remove redundant style changes from handle directive #20330

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
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/cdk/drag-drop/directives/drag-handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from '@angular/core';
import {Subject} from 'rxjs';
import {CDK_DRAG_PARENT} from '../drag-parent';
import {toggleNativeDragInteractions} from '../drag-styling';

/**
* Injection token that can be used to reference instances of `CdkDragHandle`. It serves as
Expand Down Expand Up @@ -55,9 +54,7 @@ export class CdkDragHandle implements OnDestroy {
constructor(
public element: ElementRef<HTMLElement>,
@Inject(CDK_DRAG_PARENT) @Optional() @SkipSelf() parentDrag?: any) {

this._parentDrag = parentDrag;
toggleNativeDragInteractions(element.nativeElement, false);
}

ngOnDestroy() {
Expand Down
9 changes: 8 additions & 1 deletion src/cdk/drag-drop/directives/drag.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,20 @@ describe('CdkDrag', () => {
}).not.toThrow();
}));

it('should enable native drag interactions when there is a drag handle', () => {
it('should enable native drag interactions on the drag item when there is a handle', () => {
const fixture = createComponent(StandaloneDraggableWithHandle);
fixture.detectChanges();
const dragElement = fixture.componentInstance.dragElement.nativeElement;
expect(dragElement.style.touchAction).not.toBe('none');
});

it('should disable native drag interactions on the drag handle', () => {
const fixture = createComponent(StandaloneDraggableWithHandle);
fixture.detectChanges();
const styles = fixture.componentInstance.handleElement.nativeElement.style;
expect(styles.touchAction || (styles as any).webkitUserDrag).toBe('none');
});

it('should be able to reset a freely-dragged item to its initial position', fakeAsync(() => {
const fixture = createComponent(StandaloneDraggable);
fixture.detectChanges();
Expand Down