Skip to content

Commit c505d38

Browse files
committed
fix(month-view): prevent day clicked from firing when dragging events
BREAKING CHANGE: Custom template users will now need to add a "dragActiveClass='cal-drag-active'" anywhere they use an mwlDraggable directive If using the mwlDraggable directive anywhere else in your app you will need to apply `pointer-events: none` to the element yourself when it's being dragged. This can be done with the `dragActiveClass` option Fixes #487
1 parent 2454892 commit c505d38

9 files changed

+20
-4
lines changed

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
"@angular/core": ">=6.0.0 <8.0.0"
164164
},
165165
"dependencies": {
166-
"angular-draggable-droppable": "^4.0.0-beta.4",
166+
"angular-draggable-droppable": "^4.0.0-beta.5",
167167
"angular-resizable-element": "^3.0.0",
168168
"calendar-utils": "^0.2.0-alpha.6",
169169
"positioning": "^1.3.1"

src/modules/day/calendar-day-view.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export interface DayViewEventResize {
9595
(resizing)="resizing(dayEvent, $event)"
9696
(resizeEnd)="resizeEnded(dayEvent)"
9797
mwlDraggable
98+
dragActiveClass="cal-drag-active"
9899
[dropData]="{event: dayEvent.event, isInternal: true}"
99100
[dragAxis]="{x: !snapDraggedEvents && dayEvent.event.draggable && currentResizes.size === 0, y: dayEvent.event.draggable && currentResizes.size === 0}"
100101
[dragSnapGrid]="snapDraggedEvents ? {y: eventSnapSize} : {}"

src/modules/day/calendar-day-view.scss

+4
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,8 @@
9090
padding: 8px;
9191
border: solid 1px;
9292
}
93+
94+
.cal-drag-active * {
95+
pointer-events: none;
96+
}
9397
}

src/modules/month/calendar-month-view.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ export class CalendarMonthViewComponent
344344
* @hidden
345345
*/
346346
handleDayClick(clickEvent: any, day: MonthViewDay) {
347+
console.log('clicked', clickEvent.target);
347348
// when using hammerjs, stopPropagation doesn't work. See https://github.com/mattlewis92/angular-calendar/issues/318
348349
if (!clickEvent.target.classList.contains('cal-event')) {
349350
this.dayClicked.emit({ day });

src/modules/month/calendar-month-view.scss

+4
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,8 @@
149149
opacity: 0.3;
150150
}
151151
}
152+
153+
.cal-drag-active * {
154+
pointer-events: none;
155+
}
152156
}

src/modules/month/calendar-open-day-events.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { trackByEventId } from '../common/util';
2020
*ngFor="let event of events; trackBy:trackByEventId"
2121
[ngClass]="event?.cssClass"
2222
mwlDraggable
23+
dragActiveClass="cal-drag-active"
2324
[dropData]="{event: event}"
2425
[dragAxis]="{x: event.draggable, y: event.draggable}">
2526
<span

src/modules/week/calendar-week-view.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export interface CalendarWeekViewBeforeRenderEvent {
7878
(resizing)="resizing(weekEvent, $event, dayColumnWidth)"
7979
(resizeEnd)="resizeEnded(weekEvent)"
8080
mwlDraggable
81+
dragActiveClass="cal-drag-active"
8182
[dragAxis]="{x: weekEvent.event.draggable && currentResizes.size === 0, y: false}"
8283
[dragSnapGrid]="{x: dayColumnWidth}"
8384
[validateDrag]="validateDrag"

src/modules/week/calendar-week-view.scss

+4
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,8 @@
8181
text-overflow: ellipsis;
8282
white-space: nowrap;
8383
}
84+
85+
.cal-drag-active * {
86+
pointer-events: none;
87+
}
8488
}

0 commit comments

Comments
 (0)