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.

Nested tooltips don't function as intended

See original GitHub issue

What package has an issue

@mantine/core

Describe the bug

Nested tooltips seem to inherit each-others properties leading to buggy behaviors or not showing at all.

See the linked demo where we attempt to nest a clickable Tooltip inside of a hoverable Tooltip, and instead neither fires.

What version of @mantine/hooks page do you have in package.json?

5.2.0

If possible, please include a link to a codesandbox with the reproduced problem

https://codesandbox.io/s/optimistic-meadow-95x4i9

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Possible fix

Unknown. It works with TippyJS, however they manage this.

We had a custom wrapper to also help with this, but that doesn’t help in this case either unfortunately:

function mergeRefs(refs) {
  return value => {
    refs.forEach(ref => {
      if (typeof ref === 'function') {
        ref(value);
      } else if (ref != null) {
        ref.current = value;
      }
    });
  };
}


const TooltipWrap = forwardRef(({ label, tooltipOpts = {}, children }, ref) => {
  const mergedRefs = mergeRefs([children.ref, ref]);
  return label ? (
    <Tooltip
      {...{
        label,
        // NOTE: Doesn't work even if we use ...props here
      }}
      {...tooltipOpts}
    >
      {React.cloneElement(children, { ref: mergedRefs })}
    </Tooltip>
  ) : (
    React.cloneElement(children, { ref: mergedRefs })
  );
});

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
nfbuckleycommented, Oct 21, 2022

Never mind my previous comment - there is a simpler solution which involves merging the incoming events (from the parent tooltip) with the current tooltip. I did a quick test and it appears to work. I’ll see if I can’t put together a PR.

2reactions
rtivitalcommented, Aug 22, 2022

Yes, I will try to resolve this, not sure if it is possible yet

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is material-ui's tooltip not displaying when nested in a ...
When using the approach in my code below, the tooltips will not be displayed as expected with the proper handler functions:
Read more >
nested tooltip with interactive: true · Issue #627 - GitHub
One small issue, say both tooltips are interactive, for example inner one contains long text, if you have to copy or to read...
Read more >
Tippy Tooltips [Official Support] - Add-ons - Anki Forums
This is the official support thread for my add-on Tippy Tooltips. If you encounter any issues, please post them here, as I will...
Read more >
Tooltips - Material Design
Tooltips display informative text when users hover over, focus on, or tap an element.
Read more >
Tableau Tip: Tooltip Viz - The Data School
If you're not sure what this whole tooltip viz is, I'll use my submission for ... be able to hover on top of...
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