Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Provide an easy way to enable pointer events on tippy bubbles #1163

Open
DonaldDuck313 opened this issue Apr 7, 2024 · 1 comment
Open

Comments

@DonaldDuck313
Copy link

Problem

I have a tippy bubble to which I've added a button:

const bubble = tippy("#someElement", {
    content: "<button id=\"myButton\">Click here</button>",
    allowHTML: true,
    showOnCreate: true,
    trigger: "manual",
    hideOnClick: false
});
document.querySelector("#myButton").onclick = () => alert("Do stuff");

The problem is that by default tippy bubbles have the CSS attribute pointer-events: none, so clicking the button does nothing. The only way I've found to get around this limitation is to manually select the bubble and change the CSS, which I find very ugly:

[...document.querySelectorAll("[data-tippy-root]")].at(-1).style.pointerEvents = "auto";

Solution

It would be nice if you could add an option to the tippy function that enables pointer events, so that I could do something like:

const bubble = tippy("#someElement", {
    content: "<button id=\"myButton\">Click here</button>",
    allowHTML: true,
    showOnCreate: true,
    trigger: "manual",
    hideOnClick: false,
    usePointerEvents: true    //Not currently possible, could you please add support for this?
});
document.querySelector("#myButton").onclick = () => alert("Do stuff");
@Ragnar-Oock
Copy link

you can use the interactive prop for that (see https://atomiks.github.io/tippyjs/v6/all-props/#interactive)

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

No branches or pull requests

2 participants