question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keep tooltip open while hovering over tooltip (rather than closing when leaving trigger)

See original GitHub issue

Is your feature request related to a problem? Please describe. I’ve created a navigation sidebar that, when you hover over the icon, displays a tooltip with the label for that route. I’ve got the tooltip working well, but on user testing, some of my users are trying to click on the tooltip rather than the icon.

Because I’m using useHover [const [isOpen, hoverProps] = useHover({ delayEnter: 100, delayLeave: 200 });] the tooltip closes as the user mouseLeave’s off the triggering element and tries to click the tooltip.

Describe the solution you’d like Some way/logic to stop the delayLeave from triggering if the tooltip is hovered as well. Basically if the element or tooltip is hovered then keep the tooltip open, otherwise trigger delayLeave.

Describe alternatives you’ve considered Currently I’m bumping up the delayLeave number to e.g. 500 to keep the tooltip open for longer, but this doesn’t look that great from a UX perspective.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
everweijcommented, Jul 30, 2021

Thanks for submitting this issue!

What I generally do, and here’s an example, is to not only spread the hoverProps on the trigger-element, but also on the layer-element itself. So, from the perspective of useHover() it doesn’t matter where the ‘signals’ (enter/leave) originated from, so you could attach the hoverProps (onMouseEnter / onMouseLeave) to any elements you’d like.

// minimal example

function Example() {
  const [isOver, hoverProps] = useHover({ delayLeave: 100 });
  
    const { renderLayer, triggerProps, layerProps } = useLayer({
        isOpen: isOver
    });

    return (
        <>
            {isOver &&
                renderLayer(
                    <div {...layerProps} {...hoverProps}>
                        Layer!
                    </div>
                )}
            <button {...triggerProps} {...hoverProps}>
                Trigger!
            </button>
        </>
    );
}

Does this help / answers your question?

0reactions
Gofilordcommented, Apr 6, 2022

@everweij The problem with this, is this can’t be done if I want the trigger to be click and not hover. I am now facing an issue where I nee the tooltip to support both click and hover, and I find it very troubling (if I were to do this, the click inside the tooltip will close it).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap tooltips to stay open on hover - Stack Overflow
Keep Tooltip open on mouseover + add a helper class on first mouseover (the tooltip alway triggered two mouseover events in my case...
Read more >
Tooltip: no way to keep content open on hover. - jQuery UI
As far as I can tell, there is no way to keep a tooltip open when you change focus from the tooltip parent...
Read more >
Building a simple tooltip component that never goes off screen
The idea is to set the container with position: relative while the dropdown has a position: absolute and we can use a combination...
Read more >
Tooltips - Bootstrap
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element. Trigger the tooltip via JavaScript:...
Read more >
Tooltip - Angular powered Bootstrap
When using non-manual triggers, you can control the delay to open and close the tooltip through the openDelay and closeDelay properties. Note that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found