🐛 make sure tooltip IDs are unique
This commit is contained in:
parent
5fd87a9d80
commit
2630e964d0
1 changed files with 7 additions and 4 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import React, { useState } from "react";
|
||||
import { HeaderButton, StyledTooltip } from ".";
|
||||
import ReactDOM from "react-dom";
|
||||
import { HeaderButton, StyledTooltip } from ".";
|
||||
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
interface HeaderButtonWithTextProps {
|
||||
text: string;
|
||||
|
|
@ -20,13 +22,14 @@ const HeaderButtonWithText = React.forwardRef<
|
|||
HeaderButtonWithTextProps
|
||||
>((props: HeaderButtonWithTextProps, ref) => {
|
||||
const [hover, setHover] = useState(false);
|
||||
const id = uuidv4();
|
||||
|
||||
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeaderButton
|
||||
data-tooltip-id={`header_button_${props.text}`}
|
||||
data-tooltip-id={`header_button_${id}`}
|
||||
inverted={props.inverted}
|
||||
disabled={props.disabled}
|
||||
onMouseEnter={() => {
|
||||
|
|
@ -48,10 +51,10 @@ const HeaderButtonWithText = React.forwardRef<
|
|||
</HeaderButton>
|
||||
{tooltipPortalDiv &&
|
||||
ReactDOM.createPortal(
|
||||
<StyledTooltip id={`header_button_${props.text}`} place="bottom">
|
||||
<StyledTooltip id={`header_button_${id}`} place="bottom">
|
||||
{props.text}
|
||||
</StyledTooltip>,
|
||||
tooltipPortalDiv
|
||||
tooltipPortalDiv,
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue