Skip to content

Commit

Permalink
[components] Wrap Tooltip children in div (#2047)
Browse files Browse the repository at this point in the history
Fixes a bug where the onHover didn't cover the whole element therefore
making it difficult to get the tooltip shown.

Probably because we attach the onMouseLeave and onMouseEnter onto the
individual child nodes instead of making it enclose all of them.
  • Loading branch information
Benedicte Emilie Brækken committed Oct 13, 2020
1 parent 73a2a97 commit 0fb45f1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/@sanity/components/src/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ export function Tooltip(
)

return (
<>
<div
onBlur={handleBlur}
onFocus={handleFocus}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
>
{React.cloneElement(children, {
onBlur: handleBlur,
onFocus: handleFocus,
onMouseEnter: handleMouseEnter,
onMouseLeave: handleMouseLeave,
ref: setReferenceElement
})}

Expand All @@ -113,6 +114,6 @@ export function Tooltip(
{!portalProp && popperNode}
</>
)}
</>
</div>
)
}

1 comment on commit 0fb45f1

@vercel
Copy link

@vercel vercel bot commented on 0fb45f1 Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.