react-native: onLongPress (and delayLongPress) triggers immediately
For some reason (I have no clue why) onLongPress
triggers immediately, and onPress doesn’t.
tested on : android simulator with genymotion (galaxy5) and real galaxy3 device
After adding delayLongPress
i figured out that it’s “stealing” 1000ms from the delay, and I guess the default delay is 1000, so it’s triggering immediately.
for example :
<TouchableOpacity
delayLongPress={3800}
onPress={()=>{
console.log(' onPress');
console.log(Date.now())}}
onPressIn ={()=>{
console.log('TouchableOpacity onPressIn');
console.log(Date.now())
}}
onLongPress ={(e)=>{
console.log(' onLongPress');
console.log(Date.now());
console.log(e.type); //undefined
}}
>
when I calculate : onLongPress time - onPressIn time
, I get ~2800
ms
without delayLongPress
or with delayLongPress={1000}
I get 10
-20
ms
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 9
- Comments: 34 (6 by maintainers)
Same. Confirming that this happens only with chrome debugger enabled.
This breaks only when debug JS remotely is enabled. im using VSCode debugger. this needs to be reopened
Still having this issue and only happen when connected to Chrome debugger.
+1 happening only with chrome debugger. I hope this doesn’t happens in production.
Hmm it randomly started happening, after testing on real device with RN Debugger. it was working fine, and suddenly stopped working, onLongPress is being called on quick single tap instead of onPress.
ExceptionsManager.js:71 Attempted to transition from state
RESPONDER_INACTIVE_PRESS_IN
toRESPONDER_ACTIVE_LONG_PRESS_IN
, which is not supported. This is most likely due toTouchable.longPressDelayTimeout
not being cancelled.reactConsoleErrorHandler @ ExceptionsManager.js:71console.error @ YellowBox.js:61_handleLongDelay @ Touchable.js:596proxiedMethod @ createPrototypeProxy.js:44(anonymous function) @ JSTimers.js:80callTimer @ JSTimersExecution.js:95callTimers @ JSTimersExecution.js:136__callFunction @ MessageQueue.js:236(anonymous function) @ MessageQueue.js:108guard @ MessageQueue.js:46callFunctionReturnFlushedQueue @ MessageQueue.js:107onmessage @ debuggerWorker.js:44Confirmed… this is still happening. Only when dev tools is connected tho.
Looks like the same problem, closed dev-tools (and added other display - not console.log) and it’s working fine
forgive
hello,I am go away!
A competition
it’s been inactive but still happening and should not be closed. it’s even worse lately when using react-native-router-flux because it brings up a red box when transitioning between scenes with the error mentioned by @zyxcambridge
Yes still happening… (i am on ios) Was working fine yesterday and today bam…
Confirming that this happens only with chrome debugger enabled.
Duplicate of this? #4088