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

Keydown triggers the selectDates function #2557

Closed
5 tasks done
yalperg opened this issue Apr 5, 2024 · 3 comments
Closed
5 tasks done

Keydown triggers the selectDates function #2557

yalperg opened this issue Apr 5, 2024 · 3 comments
Labels

Comments

@yalperg
Copy link
Contributor

yalperg commented Apr 5, 2024

Check that this is really a bug

  • I confirm

Reproduction link

n/a

Bug description

First double click on the slot, then click on a slot and finally press any key on the keyboard. This triggers the selectDates function and causes an error.

Here is the demo:

Ekran.Kaydi.2024-04-06.01.41.24.mov

I think this problem is caused by the _handleTerminatingEvent function, the keydown event listener is added for the escape key, but there is no control for other keys, so it emits the select event when other keys are pressed.

_handleTerminatingEvent(e) {
const selecting = this.selecting
const bounds = this._selectRect
// If it's not in selecting state, it's a click event
if (!selecting && e.type.includes('key')) {
e = this._initialEvent
}
this.selecting = false
this._removeEndListener && this._removeEndListener()
this._removeMoveListener && this._removeMoveListener()
this._selectRect = null
this._initialEvent = null
this._initialEventData = null
this._lastClickData = null
if (!e) return
let inRoot = !this.container || contains(this.container(), e.target)
let isWithinValidContainer = this._isWithinValidContainer(e)
if (e.key === 'Escape' || !isWithinValidContainer) {
return this.emit('reset')
}
if (!selecting && inRoot) {
return this._handleClickEvent(e)
}
// User drag-clicked in the Selectable area
if (selecting) return this.emit('select', bounds)
return this.emit('reset')
}

this._onEscListener = addEventListener(
'keydown',
this._handleTerminatingEvent
)

Expected Behavior

No response

Actual Behavior

No response

react-big-calendar version

1.11.2

React version

18.2

Platform/Target and Browser Versions

macOS

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
@yalperg yalperg added the bug label Apr 5, 2024
@yalperg yalperg changed the title Keydown triggers on Keydown triggers the selectDates function Apr 5, 2024
@forceddd
Copy link
Contributor

forceddd commented Apr 7, 2024

@Yuiji Does this issue still exist on version 1.11.3? I have not been able to successfully reproduce this error.

@yalperg
Copy link
Contributor Author

yalperg commented Apr 7, 2024

@forceddd I checked again and this issue does not exist on version 1.11.3. I think this PR (#2551) solved this issue, right?

@forceddd
Copy link
Contributor

forceddd commented Apr 7, 2024

@Yuiji Yes, that's what it looks like right now.

@yalperg yalperg closed this as completed Apr 7, 2024
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

2 participants