Skip to content

Commit

Permalink
fix(month-view): prevent day clicked from firing when dragging events
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mattlewis92 committed Jun 18, 2018
1 parent 2454892 commit c505d38
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"@angular/core": ">=6.0.0 <8.0.0"
},
"dependencies": {
"angular-draggable-droppable": "^4.0.0-beta.4",
"angular-draggable-droppable": "^4.0.0-beta.5",
"angular-resizable-element": "^3.0.0",
"calendar-utils": "^0.2.0-alpha.6",
"positioning": "^1.3.1"
Expand Down
1 change: 1 addition & 0 deletions src/modules/day/calendar-day-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export interface DayViewEventResize {
(resizing)="resizing(dayEvent, $event)"
(resizeEnd)="resizeEnded(dayEvent)"
mwlDraggable
dragActiveClass="cal-drag-active"
[dropData]="{event: dayEvent.event, isInternal: true}"
[dragAxis]="{x: !snapDraggedEvents && dayEvent.event.draggable && currentResizes.size === 0, y: dayEvent.event.draggable && currentResizes.size === 0}"
[dragSnapGrid]="snapDraggedEvents ? {y: eventSnapSize} : {}"
Expand Down
4 changes: 4 additions & 0 deletions src/modules/day/calendar-day-view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,8 @@
padding: 8px;
border: solid 1px;
}

.cal-drag-active * {
pointer-events: none;
}
}
1 change: 1 addition & 0 deletions src/modules/month/calendar-month-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ export class CalendarMonthViewComponent
* @hidden
*/
handleDayClick(clickEvent: any, day: MonthViewDay) {
console.log('clicked', clickEvent.target);
// when using hammerjs, stopPropagation doesn't work. See https://github.com/mattlewis92/angular-calendar/issues/318
if (!clickEvent.target.classList.contains('cal-event')) {
this.dayClicked.emit({ day });
Expand Down
4 changes: 4 additions & 0 deletions src/modules/month/calendar-month-view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,8 @@
opacity: 0.3;
}
}

.cal-drag-active * {
pointer-events: none;
}
}
1 change: 1 addition & 0 deletions src/modules/month/calendar-open-day-events.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { trackByEventId } from '../common/util';
*ngFor="let event of events; trackBy:trackByEventId"
[ngClass]="event?.cssClass"
mwlDraggable
dragActiveClass="cal-drag-active"
[dropData]="{event: event}"
[dragAxis]="{x: event.draggable, y: event.draggable}">
<span
Expand Down
1 change: 1 addition & 0 deletions src/modules/week/calendar-week-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export interface CalendarWeekViewBeforeRenderEvent {
(resizing)="resizing(weekEvent, $event, dayColumnWidth)"
(resizeEnd)="resizeEnded(weekEvent)"
mwlDraggable
dragActiveClass="cal-drag-active"
[dragAxis]="{x: weekEvent.event.draggable && currentResizes.size === 0, y: false}"
[dragSnapGrid]="{x: dayColumnWidth}"
[validateDrag]="validateDrag"
Expand Down
4 changes: 4 additions & 0 deletions src/modules/week/calendar-week-view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,8 @@
text-overflow: ellipsis;
white-space: nowrap;
}

.cal-drag-active * {
pointer-events: none;
}
}

0 comments on commit c505d38

Please sign in to comment.