Skip to content

Commit

Permalink
fix(lib): fix tooltip bot being animatable due to unique parent
Browse files Browse the repository at this point in the history
  • Loading branch information
dackmin committed Apr 28, 2021
1 parent 350409c commit 2c7e9be
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
20 changes: 13 additions & 7 deletions packages/junipero/lib/Tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ const Tooltip = forwardRef(({
return handlers;
};

const tooltipInner = (
<div className="tooltip-inner">
{ text }
<div ref={setArrowRef} style={styles?.arrow} className="arrow" />
</div>
);

const tooltip = (
<div
className={classNames(
Expand All @@ -134,8 +141,10 @@ const Tooltip = forwardRef(({
{ ...attributes?.popper || {} }
ref={setTooltipRef}
>
{ text }
<div ref={setArrowRef} style={styles?.arrow} className="arrow" />
{ animate
? animate(tooltipInner, { opened: state.opened })
: tooltipInner
}
</div>
);

Expand All @@ -155,11 +164,8 @@ const Tooltip = forwardRef(({

{ state.opened || animate || apparition === 'css'
? container
? createPortal(
animate ? animate(tooltip, { opened: state.opened }) : tooltip,
ensureNode(container)
)
: animate ? animate(tooltip, { opened: state.opened }) : tooltip
? createPortal(tooltip, ensureNode(container))
: tooltip
: null
}
</>
Expand Down
22 changes: 12 additions & 10 deletions packages/junipero/lib/Tooltip/index.styl
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
@require "../theme/colors"

.junipero.tooltip
color: $color-white
border-radius: 4px
padding: 8px 21px
text-align: center
pointer-events: none
max-width: 250px
background: $color-midnight

.arrow
position: absolute

.tooltip-inner
color: $color-white
border-radius: 4px
padding: 8px 21px
text-align: center
pointer-events: none
max-width: 250px
background: $color-midnight

.arrow
position: absolute

&[data-placement*="top"] .arrow,
&[data-placement*="bottom"] .arrow
Expand Down

0 comments on commit 2c7e9be

Please sign in to comment.