Skip to content

Commit

Permalink
Another tooltip fix
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-robert committed Nov 19, 2024
1 parent c90d20a commit 15465f8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/ClickableTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ const ClickableTooltip = ({
const label = useDisclosure();
const ref = useRef<HTMLDivElement>(null);
const handleMouseEnter = useCallback(() => {
const openTooltips = document.querySelectorAll(
'[role="tooltip"]:not([hidden])'
const focussedTooltips = Array.from(
document.querySelectorAll(".focusable-tooltip")
);
if (!openTooltips.length) {
if (
focussedTooltips.every((tooltip) => tooltip !== document.activeElement)
) {
label.onOpen();
}
}, [label]);
Expand All @@ -44,6 +46,7 @@ const ClickableTooltip = ({
return (
<Tooltip isOpen={label.isOpen} {...rest} closeOnEsc={true}>
<Flex
className={isFocusable ? "focusable-tooltip" : undefined}
onKeyDown={handleKeydown}
ref={ref}
onMouseEnter={handleMouseEnter}
Expand Down

0 comments on commit 15465f8

Please sign in to comment.