Skip to content

Commit 3632345

Browse files
authored
fix: Correct resize for multi-day event. (#2138)
1 parent 91eec18 commit 3632345

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/addons/dragAndDrop/EventContainerWrapper.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,34 @@ class EventContainerWrapper extends React.Component {
7979
const newTime = slotMetrics.closestSlotFromPoint(point, bounds)
8080

8181
let { start, end } = eventTimes(event, accessors, localizer)
82+
let newRange
8283
if (direction === 'UP') {
83-
start = localizer.min(newTime, slotMetrics.closestSlotFromDate(end, -1))
84+
const newStart = localizer.min(
85+
newTime,
86+
slotMetrics.closestSlotFromDate(end, -1)
87+
)
88+
// Get the new range based on the new start
89+
// but don't overwrite the end date as it could be outside this day boundary.
90+
newRange = slotMetrics.getRange(newStart, end)
91+
newRange = {
92+
...newRange,
93+
endDate: end,
94+
}
8495
} else if (direction === 'DOWN') {
85-
end = localizer.max(newTime, slotMetrics.closestSlotFromDate(start))
96+
// Get the new range based on the new end
97+
// but don't overwrite the start date as it could be outside this day boundary.
98+
const newEnd = localizer.max(
99+
newTime,
100+
slotMetrics.closestSlotFromDate(start)
101+
)
102+
newRange = slotMetrics.getRange(start, newEnd)
103+
newRange = {
104+
...newRange,
105+
startDate: start,
106+
}
86107
}
87108

88-
this.update(event, slotMetrics.getRange(start, end))
109+
this.update(event, newRange)
89110
}
90111

91112
handleDropFromOutside = (point, boundaryBox) => {

src/utils/TimeSlots.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export function getSlotMetrics({
8989

9090
closestSlotFromDate(date, offset = 0) {
9191
if (localizer.lt(date, start, 'minutes')) return slots[0]
92+
if (localizer.gt(date, end, 'minutes')) return slots[slots.length - 1]
9293

9394
const diffMins = localizer.diff(start, date, 'minutes')
9495
return slots[(diffMins - (diffMins % step)) / step + offset]

0 commit comments

Comments
 (0)