mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
94.13k stars 32.35k forks source link

Nightmare/Electron touch event #5430

Closed maitriyogin closed 7 years ago

maitriyogin commented 8 years ago

Hi, I'm currently experimenting with the test runner Nightmarejs and having a nightmare trying to simulate a touchTap on all MUI buttons. I'm wondering if theres a particular way to deal with touchTap in Electron and also nightmare ? I'v included

import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();

in my index.js and can happily click or touch tap those buttons in chrome/safari also via night watch via selenium. But not in Electron with Nightmarejs ... Any ideas would be hugely appreciated. /Stephen.

digitalfiz commented 8 years ago

I am also having this same problem. No touchTap events work at all :(

spearmootz commented 8 years ago

+1

lucasbento commented 8 years ago

How does onClick behave?

onTouchTap is provided by an external dependency that has already been removed on next.

dzoba commented 7 years ago

I am also experiencing this problem. Has anyone found a solution? I have the same use case as @maitriyogin with Nightmarejs.

dzoba commented 7 years ago

I found I am able to 'click' on the element programmatically with this code:

var t = new Touch({
    identifier: Date.now(),
    target: document.querySelector('button'),
    clientX: 100,
    clientY: 100,
    radiusX: 2.5,
    radiusY: 2.5,
    rotationAngle: 10,
    force: 0.5,
  });

var touchEvent = new TouchEvent('touchend', {
    cancelable: true,
    bubbles: true,
    touches: [t],
    targetTouches: [],
    changedTouches: [t],
    shiftKey: true,
  });

document.querySelector('button').dispatchEvent(touchEvent)

Many thanks to this StackOverflow comment for leading me to the answer: http://stackoverflow.com/a/42447620/935473

This can be closed.