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

Views WEEK shows an extra slot #1685

Closed
ruben-kasaz opened this issue Jun 22, 2020 · 4 comments
Closed

Views WEEK shows an extra slot #1685

ruben-kasaz opened this issue Jun 22, 2020 · 4 comments
Labels

Comments

@ruben-kasaz
Copy link

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

I want to report a bug.

What's the current behavior?

I am using react-big-calendar on my project.
I set a min and max props from 6:00 to 22:00.
The calendar renders an extra slots after the 21:00-22:00 slot.

Capture d’écran 2020-06-22 à 17 55 31

This slot goes from 22:00 to 23:00,

I want to hide this extra slot. Because, I can click on it, and it calls my onSelectSlot function, things that I don't want it to happen.

What's the expected behavior?

This slot should not appear since I put a max hours equals 22:00.

Can someone have the solution? I would appreciate that
Thank you

@vAskitsa
Copy link

This problem has been around for a long time.
I think i created one issue in September 2019 which was related to this.
I still have this problem due i don't want hide last slot with css mess.

@bytetyde
Copy link

bytetyde commented Jul 15, 2020

I've also encountered this behaviour. I think the problem comes from these lines

const totalMin = 1 + dates.diff(start, end, 'minutes') + getDstOffset(start, end)
const numGroups = Math.ceil(totalMin / (step * timeslots))

Can be found here: https://github.com/jquense/react-big-calendar/blob/master/src/utils/TimeSlots.js#L18

If the calendar is set to show e.g 09:00 to 22:00 it will calculate (22 - 9) * 60 + 1 => 781
And this extra Minute will result in the additional timeslot shown.

var numGroups = Math.ceil(totalMin / (step * timeslots));

e.g
781 / (15 * 4) => 13.0166667 which results through the Math.ceil in 14 timeslots

The additional minute was introduced here: #965

I think a fix could be subtracting the minute again when calculating the group count

var numGroups = Math.ceil((totalMin - 1) / (step * timeslots));

Not sure if there are edge cases which need to be considered. Maybe @jquense can give more context.

@cdaz5
Copy link
Contributor

cdaz5 commented Feb 12, 2021

My workaround for this was to subtract 1 minute from the max time if the max time is on the hour so for times ending on the hour it works as expected. For times that end during the hour (say 7:30) it will still render the entire 7-8 slot, but if you click on the 7:31-8pm area the time passed will be 7:30 no matter what you clicked (small edge case to the workaround but thought i'd mention it).

@cutterbl
Copy link
Collaborator

resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants