Closed
Description
Bug description
When I create a new target for the tooltip, it's no longer automatically opened.
Version of Package
^5.16.1
To Reproduce
- Find an element in the page that is currently selected, and assign a random / static ID
const [tooltipId, setTooltipId] = useState("");
const anEventHandler= () => {
const oldTargetElement = ....
currentElement.removeAttribute("data-tooltip-id");
currentElement.removeAttribute("data-tooltip-content");
const newTargetElement = document.getElementById(`${targetClass}`);
newTargetElement.setAttribute("data-tooltip-id", dataTooltipId);
newTargetElement.setAttribute("data-tooltip-content", "Hi der");
// This is a hook, and will trigger re-render
setTooltipId(tooltipId);
}
- Render as normal
// In the render
<>
<ReactTooltip id={tooltipId} place="bottom" isOpen={true} />
</>
- Repeat (1) as many times as you like, each time after initial render, you will have to hover over the element in order for the tooltip to open
Expected behavior
The current behavior is the tooltip only opens for the first element assigned the data attributes. For initial renders after that point I have to hover over the tooltip manually to open it again, I would like it to remain open (as per my code).
I have tried 2 approaches to fix this;
- Using a random ID when assigning tooltip to new element - This results in the OLD element having the tooltip on hover
- Using a static ID when assigning tooltip to new element - This results in the tooltip pointing to new element
In both cases however, I must still hover over the target element to open it.
Desktop (please complete the following information if possible or delete this section):
-Chrome, Windows 11