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

When selectable is true, click into calendar and press any key on keyboard at same time, this error appears. #2424

Open
4 of 5 tasks
quanghuyTiPiCi opened this issue Jul 22, 2023 · 11 comments
Labels

Comments

@quanghuyTiPiCi
Copy link

Check that this is really a bug

  • I confirm

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.
Screenshot 2023-07-22 171140

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

  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a react-big-calendar issue and not an implementation issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@cutterbl
Copy link
Collaborator

This error comes from using a string for a date property, instead of a true JS Date object. See our documentation on Understanding Dates

@quanghuyTiPiCi
Copy link
Author

quanghuyTiPiCi commented Jul 25, 2023

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.

New-video
image

@cutterbl
Copy link
Collaborator

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

@quanghuyTiPiCi
Copy link
Author

quanghuyTiPiCi commented Jul 25, 2023

the example Selectable in the documentation also appears this error. Is it really a bug?
image
slots is undefined

@cutterbl cutterbl reopened this Jul 26, 2023
@cutterbl
Copy link
Collaborator

@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).

@brandonparis
Copy link

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

@Pratik888800
Copy link

Not able to replicate the issue with the current version
image_2024-01-19_135744972

@quanghuyTiPiCi
Copy link
Author

quanghuyTiPiCi commented Jan 19, 2024

when mouse down into calendar and press any keyboard button, this error will occur.
image

@LorienHW
Copy link

LorienHW commented Mar 4, 2024

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

LorienHW added a commit to Outpatient/react-big-calendar that referenced this issue Mar 4, 2024
@forceddd
Copy link
Contributor

forceddd commented Apr 2, 2024

@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.

2024-04-02.15.13.55.mov

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.

2024-04-02.15.37.21.mov

@LorienHW
Copy link

LorienHW commented Apr 2, 2024

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 - #2528

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

No branches or pull requests

6 participants