Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bug where appointments can appear outside the calendar #1204

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const EXAMPLES = {
customView: 'Custom Calendar Views',
resource: 'Resource Scheduling',
dnd: 'Addon: Drag and drop',
dndresource: 'Resource Drag and drop',
}

const DEFAULT_EXAMPLE = 'basic'
Expand Down
15 changes: 15 additions & 0 deletions examples/demos/dndresource.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,27 @@ const events = [
end: new Date(2018, 0, 29, 12, 30, 0),
resourceId: 3,
},
{
id: 10,
title: 'Board meeting',
start: new Date(2018, 0, 30, 23, 0, 0),
end: new Date(2018, 0, 30, 23, 59, 0),
resourceId: 1,
},
{
id: 11,
title: 'Birthday Party',
start: new Date(2018, 0, 30, 7, 0, 0),
end: new Date(2018, 0, 30, 10, 30, 0),
resourceId: 4,
},
{
id: 12,
title: 'Board meeting',
start: new Date(2018, 0, 29, 23, 59, 0),
end: new Date(2018, 0, 30, 13, 0, 0),
resourceId: 1,
},
]

const resourceMap = [
Expand Down Expand Up @@ -103,6 +117,7 @@ class Dnd extends React.Component {
resourceTitleAccessor="resourceTitle"
onEventResize={this.resizeEvent}
defaultView="day"
showMultiDayTimes={true}
defaultDate={new Date(2018, 0, 29)}
/>
)
Expand Down
5 changes: 4 additions & 1 deletion src/utils/TimeSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ export function getSlotMetrics({ min: start, max: end, step, timeslots }) {

const rangeStartMin = positionFromDate(rangeStart)
const rangeEndMin = positionFromDate(rangeEnd)
const top = (rangeStartMin / (step * numSlots)) * 100
const top =
rangeStartMin === rangeEndMin
? (rangeStartMin / (step * numSlots)) * 98
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's going on here with 98, is there a deterministic reason to use 98%? This feels like a number that would only work with the default slot numbers.

Copy link
Contributor Author

@NathanBP NathanBP Feb 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are correct after further testing with smaller step values it does make the events not sit in the correct space. I have modified the code for this section to factor in the step value so as to allow this to now work correctly for any step value.

: (rangeStartMin / (step * numSlots)) * 100

return {
top,
Expand Down