question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple events completely hidden by another event in Day/Week views

See original GitHub issue

Do you want to request a feature or report a bug?

Bug.

What’s the current behavior?

Using Big Calendar v0.20.1. step is 30, timeslots is 2. Events are:

Event A: 1:00-3:00pm
Event B: 2:30-3:00pm
Event C: 3:00-4:30pm
Event D: 3:00-4:30pm
Event E: 4:00-5:30pm
Event F: 4:00-5:30pm
Event G: 4:30-6:00pm
Event H: 5:00-7:00pm
Event I: 5:30-7:00pm
Event J: 5:30-7:00pm
Event K: 5:30-7:00pm

I’ve been able to reproduce a rare case in which multiple overlapping events are hidden by a larger event.

screen shot 2018-11-04 at 10 03 00 am

As you can see, Events I and J are completely hidden by Event H.

I suspect it has something to do with the onSameRow function in DayEventLayout.js:

/**
 * Return true if event a and b is considered to be on the same row.
 */
function onSameRow(a, b, minimumStartDifference) {
  return (
    // Occupies the same start slot.
    Math.abs(b.start - a.start) < minimumStartDifference ||
    // A's start slot overlaps with b's end slot.
    (b.start > a.start && b.start < a.end)
  )
}

I see that in #910, there was a reversal in the direction of the comparison between a and b’s start and end slots. However, if I add the original check back in and check both directions:

function onSameRow(a, b, minimumStartDifference) {
  return (
    // Occupies the same start slot.
    Math.abs(b.start - a.start) < minimumStartDifference ||
    // A's start slot overlaps with b's end slot.
    (b.start > a.start && b.start < a.end) ||
    (a.start > b.start && a.start < b.end)
  )
}

I end up with the following layout of events:

screen shot 2018-11-04 at 10 02 37 am

As you can see, all events are now visible. Any thoughts, @bgelineau? Would checking a and b’s time slots in both directions for the same row computation be the right fix here? I can make a PR to add the check back in if so.

What’s the expected behavior?

All events should be shown.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
drewtonynguyencommented, Nov 5, 2018

Thanks @bgelineau. I tested changing the sortByRender method as so, removing the logic you mentioned:

function sortByRender(events) {
  const sortedByTime = sortBy(events, ['startMs', e => -e.endMs])

  return sortedByTime
}

and my example now looks like:

screen shot 2018-11-05 at 9 58 42 am

2reactions
bgelineaucommented, Nov 5, 2018

Hi @drewtonynguyen, with your example, you are correct that a and b’s times should be compared in both directions. However it has some unfortunate side-effects, like the perfectly correct :

one sided

becoming

both sides

and

2-1

becoming

2-2

From what I see, the problem stems from doing the computation of rows in the order given by sortByRender and not just in the order (‘startMs’, ‘-endMS’).

@jquense : why the complex logic in https://github.com/intljusticemission/react-big-calendar/blob/master/src/utils/DayEventLayout.js#L105 given that the rows computation only require the first line? Is it to alternate the rendering between non-overlapping events of the same row like in the following screenshot in order to increase readability?

alternate

I don’t see another use case and it creates the problems told above, where we have to choose between two incorrect renderings (@drewtonynguyen’s being less incorrect).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple events completely hidden by another event in Day ...
I've been able to reproduce a rare case in which multiple overlapping events are hidden by a larger event.
Read more >
Set up or delete a repeating event in Calendar on Mac
In the Calendar app on your Mac, select one or more occurrences of a repeating event. Shift-click to select multiple events. Press Delete,...
Read more >
Customize your calendar - Google Workspace Learning Center
View a calendar by day, week, month, or year; View your schedule; Hide or show weekends; Hide or show declined events. To view...
Read more >
How GCalPlus can help you use Google Calendar ... - YouTube
Show More Events in Month View : with this option you'll get see at least ... several custom styles to Google Calendar -...
Read more >
12 Google Calendar Tricks You're Probably Not Using | PCMag
Use Google Calendar to make a Google Doc of meeting notes for your events with multiple attendees. All you have to do is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found