schedule-x icon indicating copy to clipboard operation
schedule-x copied to clipboard

Defining no maxDate defaults to the end of the next year

Open jasonsaayman opened this issue 1 year ago • 3 comments

Context:

  • Browser [All]
  • Browser-version [All]
  • Schedule-X version [All]

Describe the bug

A max date is being set in packages/date-picker/src/utils/stateful/config/config.impl.ts for the date picker. This leads to you being unable to scroll past this date with the back and forward buttons.

To Reproduce

Steps to reproduce the behaviour:

  1. Go to the hosted example
  2. Click on the forward chevron button until you get to December 2025
  3. You will not be able to scroll past December

Expected behaviour

I don't know if this is expected, but the docs need to be adjusted if it is.

Screenshots

2024-09-10 13 50 13

jasonsaayman avatar Sep 10 '24 11:09 jasonsaayman

This is a regression.

When I started building the project, there was no max date feature, but I didn't want to render more years than 1 year ahead in the date picker year view by default. Then I added a maxDate feature, and seems like I accidentally used the same default date for that, as for the years rendered in the year view.

Thanks for reporting!

tomosterlund avatar Sep 10 '24 12:09 tomosterlund

@tomosterlund, which way do you want to go with the fix? I would be prepared to PR; I need to know if you want to update the docs or remove the default and then I will start 😄

jasonsaayman avatar Sep 11 '24 07:09 jasonsaayman

I’d say the desired behavior is:

  1. year view in date picker should only display up until current year + 1 OR we start adding more years by default, but scroll to the year of selectedDate when opening the view
  2. no maxDate in date picker per default

I’ll gladly have a look at any PR here 😊

tomosterlund avatar Sep 11 '24 08:09 tomosterlund

decided on a slightly different approach:

  1. keep min- and max dates in date picker, but increase default to current year + 50 (reduced complexity a fair bit compared to allowing an undefined date)
  2. in v3 introduce breaking change in calendar, where calendar + date picker share a common min- max date per default

tomosterlund avatar Oct 10 '24 06:10 tomosterlund

awesome thanks so much @tomosterlund

jasonsaayman avatar Oct 10 '24 08:10 jasonsaayman