Skip to content

Commit 115ee1f

Browse files
authoredAug 10, 2022
fix: don't prevent enter key from triggering the onClick event when filterTaps is true (#531)
1 parent 07d312b commit 115ee1f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

‎.changeset/red-games-compare.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@use-gesture/core': patch
3+
---
4+
5+
fix: don't let Enter key preventDefault on onClick when filterTaps is true.

‎packages/core/src/engines/DragEngine.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ export class DragEngine extends CoordinatesEngine<'drag'> {
252252
}
253253

254254
pointerClick(event: MouseEvent) {
255-
if (!this.state.tap) {
255+
// event.detail indicates the number of buttons being pressed. When it's
256+
// null, it's likely to be a keyboard event from the Enter Key that could
257+
// be used for accessibility, and therefore shouldn't be prevented.
258+
// See https://github.com/pmndrs/use-gesture/issues/530
259+
if (!this.state.tap && event.detail > 0) {
256260
event.preventDefault()
257261
event.stopPropagation()
258262
}

0 commit comments

Comments
 (0)
Please sign in to comment.