WickyNilliams / cally

Small, feature-rich calendar components
https://wicky.nillia.ms/cally/
MIT License
1.06k stars 12 forks source link

Ability to page by one month at a time #46

Closed Cata1989 closed 4 weeks ago

Cata1989 commented 1 month ago

Scenario:

I have a multi-selectable calendar with months="1" to display one month per next/prev button press. I aim to display two months at a time, moving one month forward/backward per button press (e.g., May/June => June/July).

Problem:

Selecting dates from the second displayed month causes the calendar to jump to the next month. Setting months="2" matches the elements and works correctly, but the prev/next buttons then jump two months (e.g., May/June => July/August), which is not desired.

CodePen Example: https://codepen.io/Catalin-Lungan/pen/JjqozOe

Expected Resolution:

Currently, it is expected that the 'months' prop matches the number of elements, as the pagination logic moves by the number of months specified. It would be very useful to have a setting that allows configuring the pagination to move by a custom number of months, which would resolve the issue we're experiencing.

WickyNilliams commented 4 weeks ago

hey i just made a PR that allows you to set pageBy="single", which i think should give you the behavior you want. see #50.

can you take a look at it?

Cata1989 commented 4 weeks ago

Hey @WickyNilliams , thank you for taking the time to look into this.

Yes, I've reviewed the changes in the PR, particularly the testing part, and the pageBy prop did the trick. I guess this solution will work great for us. Using pageBy="single" | "months" , pagination will be independent of the months prop, which is excellent.

WickyNilliams commented 4 weeks ago

That's right. I'll get this merged and released today

WickyNilliams commented 4 weeks ago

Released in 0.7.0

WickyNilliams commented 3 weeks ago

Just released 0.7.1 that contains some small enhancements to the pagination logic as i wasn't quite happy with how it behaved. It feels more natural now