GeekyAnts / GeekyAnts/NativeBase

onPress triggers twice, when activated via Enter key

Open
#5,800 0 comments 0 reactions 0 assignees View on GitHub
bug triage v3
Dominant language
TypeScript
Stars
20.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

### Description

When using the onPress prop on the Button component the function get's called twice when used a enter key via keyboard

### CodeSandbox/Snack link

https://snack.expo.dev/@seemran.xec/nativebase-template

### Steps to reproduce

First time onPress is called when pressing the Enter key down and the second time it is called when releasing the Enter key.

Expected behavior
onPress is only called once, like it is when using Space key oder pressing the button with the mouse.

Steps to reproduce
Use and apply an onPress handler to it
Set a disabled state inside the onPress handler
Put some console.log inside the onPress handler
Activate your button using the keyboard (tab), pressing the Enter key
See your console.log twice in the console

Workaround
Need to use onPressIn instead of onPress
### NativeBase Version

3.4.28

### Platform

- [ ] Android
- [ ] CRA
- [X] Expo
- [ ] iOS
- [ ] Next

### Other Platform

_No response_

### Additional Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.