react-infinite-calendar icon indicating copy to clipboard operation
react-infinite-calendar copied to clipboard

Disabling days does not work as expected when used with "weekStartsOn" option

Open boopalanjayaraman opened this issue 5 years ago • 1 comments

Hi,

Let me start by saying how much I like react infinite calendar and how useful this has turned out to be. This is a life saver.

There is a minor issue here. Disabling days using "disabledDays" attribute does not work well with "weekStartsOn" attribute. Without the latter, it works fine.

I wanted to disable the weekend dates, so I initially wrote it as disabledDays = {[0, 6]} corresponding to sun and sat days. And then I wanted my week to start on Monday, so I had added

locale={{
        weekStartsOn: 1
      }}

This does change the week's starting day but enables clicking on sundays. It does not fully disable them, and the click eventhandler is triggered.

Try this with having locale attribute on and off.


return (
    <InfiniteCalendar
      disabledDays={[0, 1, 2, 3, 4, 5, 6]}
      locale={{
        weekStartsOn: 1
      }}
    />
  );

You can see it happening in the given sandbox.

https://codesandbox.io/s/modest-sinoussi-6s85o?file=/src/index.js:263-305

Thanks.

boopalanjayaraman avatar Sep 15 '20 16:09 boopalanjayaraman

disabledDays={[0, 1, 2, 3, 4, 5, 6, 7]}

seems to work, while disabledDays={[1, 2, 3, 4, 5, 6, 7]} leaves nov 1st enabled, but sundays disabled 🤔

scsskid avatar Oct 19 '20 14:10 scsskid