Skip to content

Commit f565162

Browse files
committed
fix(tooltip): hide tooltip when dragging starts
1 parent 692f075 commit f565162

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

projects/angular-calendar/src/modules/common/calendar-tooltip.directive.ts

+4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ export class CalendarTooltipDirective implements OnDestroy, OnChanges {
9999
this.tooltipRef.instance.customTemplate = this.customTemplate;
100100
this.tooltipRef.instance.event = this.event;
101101
this.tooltipRef.changeDetectorRef.markForCheck();
102+
103+
if (!this.contents) {
104+
this.hide();
105+
}
102106
}
103107
}
104108

projects/angular-calendar/test/calendar-week-view.component.spec.ts

+45
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,51 @@ describe('calendarWeekView component', () => {
380380
fixture.destroy();
381381
}));
382382

383+
it('should hide the tooltip when dragging', fakeAsync(() => {
384+
const fixture: ComponentFixture<CalendarWeekViewComponent> = TestBed.createComponent(
385+
CalendarWeekViewComponent
386+
);
387+
eventTitle.weekTooltip = (e: CalendarEvent) => {
388+
return `title: ${e.title}`;
389+
};
390+
fixture.componentInstance.viewDate = new Date('2016-06-01');
391+
fixture.componentInstance.events = [
392+
{
393+
start: new Date('2016-05-30'),
394+
end: new Date('2016-06-02'),
395+
title: 'foo <b>bar</b>',
396+
color: {
397+
primary: 'blue',
398+
secondary: '',
399+
},
400+
draggable: true,
401+
},
402+
];
403+
fixture.componentInstance.ngOnChanges({ viewDate: {}, events: {} });
404+
fixture.detectChanges();
405+
const event: HTMLElement = fixture.nativeElement.querySelector(
406+
'.cal-event'
407+
);
408+
triggerDomEvent('mouseenter', event);
409+
fixture.detectChanges();
410+
flush();
411+
expect(document.body.querySelector('.cal-tooltip')).to.be.ok;
412+
const eventPosition = event.getBoundingClientRect();
413+
triggerDomEvent('mousedown', event, {
414+
clientX: eventPosition.left,
415+
clientY: eventPosition.top,
416+
button: 0,
417+
});
418+
fixture.detectChanges();
419+
triggerDomEvent('mousemove', event, {
420+
clientX: eventPosition.left,
421+
clientY: eventPosition.top + 100,
422+
});
423+
fixture.detectChanges();
424+
expect(document.body.querySelector('.cal-tooltip')).not.to.be.ok;
425+
fixture.destroy();
426+
}));
427+
383428
it('should allow the start of the week to be changed', () => {
384429
const fixture: ComponentFixture<CalendarWeekViewComponent> = TestBed.createComponent(
385430
CalendarWeekViewComponent

0 commit comments

Comments
 (0)