Open quanghuyTiPiCi opened 1 year ago
This error comes from using a string for a date property, instead of a true JS Date object. See our documentation on Understanding Dates
I used the correct JS Date object according to the documentation, but the error persists. Left click and any key in the same time. Version <= 0.39.7 work.
That getDate
error only shows if some date is not a JS Date, whether it's a calendar prop or an event's start
or end
, something is not a true JS Date
the example Selectable in the documentation also appears this error. Is it really a bug? slots is undefined
@quanghuyTiPiCi I'm sorry. I see what you're doing now. Seeing the code you point out, it looks as if there may not be any slots
defined here. I've reopened the bug. I'll take a look as soon as I'm able (unless anyone else has a moment to look).
Just here to +1 on this bug, took me a while to figure out what was happening but can confirm we're seeing this bug as well on v1.8.2
Not able to replicate the issue with the current version
when mouse down into calendar and press any keyboard button, this error will occur.
we see this all the time - i think whats happening is that handleSelectSlot
sets the _pendingSelection
but then calls selectDates
on a timer, and before selectDates
executes something else calls clearSelection
which empties out the _pendingSelection
array. Maybe this means some other action is already in progress and so it would be ok to simply return early from selectDates
if _pendingSelection
is empty? @cutterbl
Edit: will submit a PR
@cutterbl @LorienHW @quanghuyTiPiCi I think this is a Selector
problem. When we hold down the left button and then press the keyboard, the Selector
will emit the select
event instead of the click
event. But there is no selection area at this time, and then we get this error.
In addition, the Selector does not clear the previous selection area, which creates another bug.
https://github.com/jquense/react-big-calendar/assets/63057542/b1f9a1e7-c26d-4abc-be77-7ccb8ce759ca
I modified some logic in the Selector
. When this happens, the Selector
will emit the click
event, and every time it terminates, the previous state will be cleared. Can you check the PR to see if there are other problems?
This is the effect after modification.
https://github.com/jquense/react-big-calendar/assets/63057542/c03de3cc-885f-41d5-85c3-f6cbc26acf25
the issue also repros just by clicking around a lot. the handleSelectSlot
function sets the _pendingSelection
and then uses a setTimeout to call the selectDates
. Because its not called synchronously there is an opportunity for clearSelection
to be called by something else (for example a key press), and empties out the _pendingSelection array. So I think either handleSelectSlot
needs to call selectDates
synchronously OR just make sure there is something in _pendingSelection
before attempting to process it which is what my PR does. The change i submitted does fix the issue, and seems to work correctly. So I'd put it in as a safe guard anyway just to be sure - https://github.com/jquense/react-big-calendar/pull/2528
Check that this is really a bug
Reproduction link
https://codesandbox.io/s/gracious-panini-5jwfwq?file=/src/App.js
Bug description
When selectable is true, click into calendar and press any key on keyboard at same time, this error appears.
Expected Behavior
No response
Actual Behavior
No response
react-big-calendar version
1.8.1
React version
18.2.0
Platform/Target and Browser Versions
Chrome, Firefox, etc...
Validations
Would you like to open a PR for this bug?