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

disabledDates ranges but inclusive #183

Open
NindaKhairunisa opened this issue Oct 13, 2022 · 3 comments
Open

disabledDates ranges but inclusive #183

NindaKhairunisa opened this issue Oct 13, 2022 · 3 comments

Comments

@NindaKhairunisa
Copy link

Hi,
I just wondered it is possible to do disableDates with ranges but inclusive?
For example i want datepicker is open in October 2019 and October 2022 only.
I can't figure out how to do it
Thank you

@mst101
Copy link
Contributor

mst101 commented Oct 14, 2022

Not currently... but you can get around this with something like the following:

<Datepicker
  :open-date='new Date(2019, 9, 1)'
  :disabled-dates="{
    to: new Date(2019, 9, 1),
    from: new Date(2021, 9, 31),
    ranges: [
      {
        from: new Date(2019, 9, 31),
        to: new Date(2021, 9, 1),
      }
    ]
  }"
/>

N.B. I added an open-date as without this, the calendar opens on today's month with the focus on the previous button. We should probably amend this so that - by default - the calendar focuses the last available date?

@NindaKhairunisa
Copy link
Author

@mst101 thank you it work sorry not replying for a week

@mst101
Copy link
Contributor

mst101 commented Oct 20, 2022

You're welcome.

Personally, I'm not a great fan of the way these to/from dates work currently... I'd prefer it if they were INCLUSIVE i.e. in the above example, you would disable all dates up to (and including) 30th September 2019, and also from 1st October 2021 and beyond. You'd also have a disabled date range between the two years i.e. from 1st November 2019 up to (and including) 30th September 2021. Would that make more sense to you?

<Datepicker
  :open-date='new Date(2019, 9, 1)'
  :disabled-dates="{
    to: new Date(2019, 8, 30),
    from: new Date(2021, 10, 1),
    ranges: [
      {
        from: new Date(2019, 10, 1),
        to: new Date(2021, 8, 30),
      }
    ]
  }"
/>

@MrWook - what are your thoughts on this? I did raise this in #176 but have kept things as they were for now. Happy to submit a PR, if you like?

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

No branches or pull requests

2 participants