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.

Tooltip does not work when using unique IDs within a table component

See original GitHub issue

I’m actually using ag-grid to render some html along with ReactTooltip in a cell of a table. I actually use React components to render each cell and within each react component, I embed an unique ReactTooltip. I actually want to hover a validation error if the cell has an error from user input.

In my render method, I have the following

return (
                <div>
                    <ReactTooltip id={uniqueID} type="error" effect="float" />
                       <div data-tip data-for={uniqueID} >
                               {cell.stringValue}
                    </div>
                </div>
            );

It’s weird, just for testing purposes I used a static and constant string for the id, the tool tip will render on the first render but after the cell is rerendered, the tooltip disappears.

Gif of ReactTooltips having the same ID: tooltipbug

Gif of me inspecting the cell and the html markup of the corresponding ReactToolTip

tooltip1

When do I use uniqueIDs for each ReactTooltip within a cell of a table, the tooltip simply does not show.

Gif of ReactTooltips having unique IDs with the same exact code, everything is the same exact uniqueID is different for each cell and each id of ReactToolTip

tooltipbug2

I’ve tried putting ReactTooltip.rebind() in my React Component’s componentDidUpdate() for each cell in hopes of tooltips being associated with the appropriate cell but to no avail.

Any input would be much appreciated.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
tuancaraballocommented, May 23, 2020

I had a similar issue: I had a table of tasks and the tooltip wouldn’t show when clicking on the one of the edit buttons. Screen Shot 2020-05-23 at 7 26 01 AM

What I ended up doing was calling rebuild in componentDidMount

 componentDidMount() {
    this.setState({...someState I had to set first}, () => ReactTooltip.rebuild()
 }

I’m using reactTooltip’s getContent function to customize my tooltip:

Screen Shot 2020-05-23 at 7 32 24 AM

Hope it helps

3reactions
oleksiivasylchenkocommented, Jan 8, 2019

I solved it using ReactTooltip.show and hide

<span className={style.mainBox} ref={(c) => { this.ref = c; }} 
      data-tip={`${item.name} ID`} data-for={id}
      onMouseOver={() => { ReactTooltip.show(this.ref); }}
      onMouseLeave={() => { ReactTooltip.hide(this.ref); }}
>
  {template}
  {isLastItem ? null: ', '}
  <ReactTooltip id={id} place="top" className="tooltip" type="light" />
</span>

Works fine for me with ag-grid cells now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tooltip does not work when using unique IDs within a table ...
When do I use uniqueIDs for each ReactTooltip within a cell of a table, the tooltip simply does not show. ... I've tried...
Read more >
Reactstrap Tooltip throws target could not be identified in the ...
Therefore, I decided to append a random string to the tooltip in order to get unique IDs like this: // instead of just...
Read more >
Tooltip - Examples - Components - Atlassian Design System
A tooltip is a floating, non-actionable label used to explain a user interface element or feature.
Read more >
ARIA: tooltip role - Accessibility - MDN Web Docs - Mozilla
A tooltip is a contextual text bubble that displays a description for an element that appears on pointer hover or keyboard focus.
Read more >
ARIA1: Using the aria-describedby property to provide ... - W3C
Note: The aria-describedby property is not designed to reference descriptions on an external resource — since it is an ID, it must reference...
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