Skip to content

Commit bbe1109

Browse files
authored
fix: zero duration no-overlap events (jquense#2213)
Corrects issue with the no-overlap algorithm with events that have no duration
1 parent c2bd6b8 commit bbe1109

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/utils/layout-algorithms/no-overlap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function ({
5151
const y4 = se2.style.top + se2.style.height
5252

5353
// be friends when overlapped
54-
if ((y3 <= y1 && y1 < y4) || (y1 <= y3 && y3 < y2)) {
54+
if ((y3 <= y1 && y1 <= y4) || (y1 <= y3 && y3 <= y2)) {
5555
// TODO : hashmap would be effective for performance
5656
se1.friends.push(se2)
5757
se2.friends.push(se1)

stories/Layout.stories.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ export default {
1313

1414
const Template = (args) => <Calendar {...args} />
1515

16+
const defaultDate = new Date()
17+
1618
export const EventLayout = Template.bind({})
1719
EventLayout.args = {
1820
defaultView: Views.DAY,
19-
defaultDate: new Date(),
21+
defaultDate,
2022
timeslots: 4,
2123
events: createEvents(1),
2224
}
@@ -174,3 +176,26 @@ export const ZeroDurationOddities = () => {
174176
/>
175177
)
176178
}
179+
180+
export const ZeroDurationOverlap = () => {
181+
return (
182+
<DragAndDropCalendar
183+
defaultDate={defaultDate}
184+
events={[
185+
{
186+
title: 'event a',
187+
start: defaultDate,
188+
end: defaultDate,
189+
},
190+
{
191+
title: 'event b',
192+
start: defaultDate,
193+
end: defaultDate,
194+
},
195+
]}
196+
dayLayoutAlgorithm={'no-overlap'}
197+
scrollToTime={defaultDate}
198+
defaultView={Views.WEEK}
199+
/>
200+
)
201+
}

stories/helpers/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ const localizer = momentLocalizer(moment)
2222
export const date = (...args) => moment(...args).toDate()
2323

2424
export const Calendar = (props) => (
25-
<BaseCalendar localizer={localizer} {...props} />
25+
<div style={{ height: 650 }}>
26+
<BaseCalendar localizer={localizer} {...props} />
27+
</div>
2628
)
2729

2830
export const DragAndDropCalendar = withDragAndDrop(Calendar)

0 commit comments

Comments
 (0)