Skip to content

Commit

Permalink
fix: Correct resize for multi-day event. (jquense#2138)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvgoel92 authored Mar 10, 2022
1 parent 91eec18 commit 3632345
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/addons/dragAndDrop/EventContainerWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,34 @@ class EventContainerWrapper extends React.Component {
const newTime = slotMetrics.closestSlotFromPoint(point, bounds)

let { start, end } = eventTimes(event, accessors, localizer)
let newRange
if (direction === 'UP') {
start = localizer.min(newTime, slotMetrics.closestSlotFromDate(end, -1))
const newStart = localizer.min(
newTime,
slotMetrics.closestSlotFromDate(end, -1)
)
// Get the new range based on the new start
// but don't overwrite the end date as it could be outside this day boundary.
newRange = slotMetrics.getRange(newStart, end)
newRange = {
...newRange,
endDate: end,
}
} else if (direction === 'DOWN') {
end = localizer.max(newTime, slotMetrics.closestSlotFromDate(start))
// Get the new range based on the new end
// but don't overwrite the start date as it could be outside this day boundary.
const newEnd = localizer.max(
newTime,
slotMetrics.closestSlotFromDate(start)
)
newRange = slotMetrics.getRange(start, newEnd)
newRange = {
...newRange,
startDate: start,
}
}

this.update(event, slotMetrics.getRange(start, end))
this.update(event, newRange)
}

handleDropFromOutside = (point, boundaryBox) => {
Expand Down
1 change: 1 addition & 0 deletions src/utils/TimeSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function getSlotMetrics({

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

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

0 comments on commit 3632345

Please sign in to comment.