Skip to content

Moving to React Portal after touchstart swallows future touch events #13113

Closed
@alexreardon

Description

@alexreardon

Do you want to request a feature or report a bug?

Bug 🐞

What is the current behavior?

When you move a component into a React Portal in response to a touchstart the touchmove and touchend events are swallowed for the rest of the interaction

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

Example: https://codesandbox.io/s/nr75vkklnm

You will either need to be on touch device, or enable touch sensors in your browser to see this

Steps:

  1. add a onTouchStart listener to a component
  2. in response to onTouchStart move the component into a Portal
  3. touchmove events and the touchend events are then blocked for the rest of the touch interaction

If the component is already in a component before the touchstart event then the events are emitted correctly: https://codesandbox.io/s/v54x54vp5

I have also created a vanilla js example that has a portal implementation. It moves the element into a portal after touch start. It is correctly allowing touch touchmove and touchend events: https://codesandbox.io/s/r4mn0yj6po

What is the expected behavior?

That the touchmove and touchend events are published

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Reproduced bug in Firefox and Chrome

React version: tested on 16.1, 16.3 and 16.4.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions