Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On touch devices, tooltip stays open until another element is tapped #358

Open
srmagura opened this issue Mar 26, 2022 · 4 comments
Open

Comments

@srmagura
Copy link

Repro Steps

  1. Open my CodeSandbox which kind of demonstrates the issue: https://codesandbox.io/s/tippyjs-react-disable-touch-3csybd?file=/src/App.tsx
  2. Open the "preview pane" in a new Chrome tab and enter responsive design mode. Responsive design mode causes your mouse movements & clicks to behave like touch events on a mobile device.
  3. Click the "Hover / click me" box.

Actual Behavior

You should see a single message in the console: "mouseEnter". This means that the mouseEnter event has fired but mouseLeave has not fired. I have no idea why the browser triggers mouseEnter when simulating a touch device.

In the Sandbox, the mouseEnter does not actually cause the tooltip to show, and I'm not sure why this is. In two of my real applications, tapping a Tippy-wrapped element in responsive design mode does cause the tooltip to appear.

And since the mouseLeave event never fires, the tooltip stays visible until the user taps another element. This can be undesirable in some cases — for example, tapping the Tippy-wrapped element opens a modal dialog in my application, and the tooltip displays over top of the dialog.

Desired Behavior

I want to just disable the Tippy entirely on touch devices so that the tooltip only shows when hovering with a mouse. I can't figure out how to do this since the touch devices are triggering mouseEnter.

Additional Context

All testing done with latest versions: tippy.js 6.3.7 and @tippyjs/react 4.2.6.

@atomiks
Copy link
Owner

atomiks commented Mar 26, 2022

touch={false}

@srmagura
Copy link
Author

🤦‍♀️🤦‍♀️🤦‍♀️

Thank you so much. I was so focused on the trigger prop that I completely missed touch. I would like to prepare a tiny documentation PR to clarify the behavior of trigger="mouseenter" and how this relates to the touch prop.

Since the docs state that the default is touch={true}, any idea why tapping the element in my CodeSandbox does not show the tooltip?

@srmagura
Copy link
Author

Hey @atomiks, are you willing to accept a docs PR related to this?

@dakur
Copy link

dakur commented Sep 27, 2022

Thank you so much. I was so focused on the trigger prop that I completely missed touch.

Exactly the same happened to me today. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants