Selaa lähdekoodia

make unselect better

Adam Shaw 7 vuotta sitten
vanhempi
sitoutus
86998d8772

+ 5 - 2
src/Calendar.ts

@@ -769,6 +769,7 @@ export default class Calendar {
 
 
   setDateProfile(dateProfile: DateProfile) {
+    this.unselect()
     this.dispatch({
       type: 'SET_DATE_PROFILE',
       dateProfile: dateProfile
@@ -1035,8 +1036,10 @@ export default class Calendar {
 
   // public method
   unselect(pev?: PointerDragEvent) {
-    this.dispatch({ type: 'UNSELECT_DATES' })
-    this.triggerDateUnselect(pev)
+    if (this.state.dateSelection) {
+      this.dispatch({ type: 'UNSELECT_DATES' })
+      this.triggerDateUnselect(pev)
+    }
   }
 
 

+ 1 - 0
src/interactions/EventDragging.ts

@@ -105,6 +105,7 @@ export default class EventDragging { // TODO: rename to EventSelectingAndDraggin
     }
 
     if (this.isDragging) {
+      initialCalendar.unselect(ev) // unselect *date* selection
       initialCalendar.publiclyTrigger('eventDragStart', [
         {
           el: this.subjectSeg.el,

+ 1 - 0
src/interactions/EventResizing.ts

@@ -68,6 +68,7 @@ export default class EventDragging {
 
     this.draggingSeg = this.querySeg(ev)
 
+    calendar.unselect()
     calendar.publiclyTrigger('eventResizeStart', [
       {
         el: this.draggingSeg.el,

+ 0 - 10
src/reducers/main.ts

@@ -42,20 +42,10 @@ function reduceDateProfile(currentDateProfile: DateProfile | null, action: Actio
 
 function reduceDateSelection(currentSelection: DateSpan | null, action: Action, calendar: Calendar) {
   switch (action.type) {
-
     case 'SELECT_DATES':
       return action.selection
-
-    case 'SET_DATE_PROFILE': // happens on a view-change as well
-      // clear selection if dates are changing.
-      // we need to notify the global context that his happened (strange place to do this).
-      if (currentSelection) {
-        calendar.unselect()
-      } // will fall thru...
-
     case 'UNSELECT_DATES':
       return null
-
     default:
       return currentSelection
   }