Skip to content

Touchable onPress called twice #1078

@tafelito

Description

@tafelito

The problem
I noticed that the Touchable onPress event is being fired twice. I found that you fixed this here but digging into the source code I found that you are assuming the mouse event is not the same if the time between the events are less than 250ms. The issue is that in my case, the time difference is sometimes greater than 250 (253 255 sometimes) so the mousedown event is not filtered after the touch

How to reproduce
Not sure how to reproduce as a isolated case. I know the issue is the time difference, but I'm not sure if the issue is something different that is causing a delay greater than expected.
I'm using react-router and I noticed this happening when navigating from one screen to another.

When the touch event is fired, Route A is unmounted, route B is mounted, then mouse event is fired.
So I have a link component that is present in both routes. If I don't include the Link component in route B, then the event is not fired, even tho the time difference is greater than 250ms

Expected behavior
Touchable onPress event to fired once
Environment (include versions). Did this work in previous versions?

  • React Native for Web (version): 0.8.9
  • React (version): 16.4
  • Browser: any

Could something else be causing a delay on the event getting fired? It doesn't happen all the time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions