Skip to content
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
26 changes: 25 additions & 1 deletion src/lib/tooltip/tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ describe('MatTooltip', () => {
ScrollableTooltipDemo,
OnPushTooltipDemo,
DynamicTooltipsDemo,
TooltipOnTextFields
TooltipOnTextFields,
TooltipOnDraggableElement,
],
providers: [
{provide: Platform, useFactory: () => platform},
Expand Down Expand Up @@ -795,6 +796,15 @@ describe('MatTooltip', () => {
expect(instance.textarea.nativeElement.style.userSelect).toBeFalsy();
expect(instance.textarea.nativeElement.style.webkitUserSelect).toBeFalsy();
});

it('should clear the `-webkit-user-drag` on draggable elements', () => {
const fixture = TestBed.createComponent(TooltipOnDraggableElement);

fixture.detectChanges();

expect(fixture.componentInstance.button.nativeElement.style.webkitUserDrag).toBeFalsy();
});

});

});
Expand Down Expand Up @@ -900,6 +910,20 @@ class TooltipOnTextFields {
@ViewChild('textarea') textarea: ElementRef;
}

@Component({
template: `
<button
#button
style="-webkit-user-drag: none;"
draggable="true"
matTooltip="Drag me"></button>
`,
})
class TooltipOnDraggableElement {
@ViewChild('button') button: ElementRef;
}


/** Asserts whether a tooltip directive has a tooltip instance. */
function assertTooltipInstance(tooltip: MatTooltip, shouldExist: boolean): void {
// Note that we have to cast this to a boolean, because Jasmine will go into an infinite loop
Expand Down
7 changes: 7 additions & 0 deletions src/lib/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ export class MatTooltip implements OnDestroy {
element.style.webkitUserSelect = element.style.userSelect = '';
}

// Hammer applies `-webkit-user-drag: none` on all elements by default,
// which breaks the native drag&drop. If the consumer explicitly made
// the element draggable, clear the `-webkit-user-drag`.
if (element.draggable && element.style['webkitUserDrag'] === 'none') {
element.style['webkitUserDrag'] = '';
}

_focusMonitor.monitor(element).pipe(takeUntil(this._destroyed)).subscribe(origin => {
// Note that the focus monitor runs outside the Angular zone.
if (!origin) {
Expand Down