Skip to content

Commit 24b2593

Browse files
revert: holdPositionOnRender
1 parent 211df3d commit 24b2593

File tree

5 files changed

+3
-47
lines changed

5 files changed

+3
-47
lines changed

src/App.tsx

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable jsx-a11y/click-events-have-key-events */
33
import { TooltipController as Tooltip } from 'components/TooltipController'
44
import { IPosition } from 'components/Tooltip/TooltipTypes.d'
5-
import React, { useMemo, useState } from 'react'
5+
import React, { useState } from 'react'
66
import { inline, offset } from '@floating-ui/dom'
77
import styles from './styles.module.css'
88

@@ -23,26 +23,6 @@ function App() {
2323
setAnchorId(target.id)
2424
}
2525

26-
const [which, setWhich] = useState<'1' | '2'>('1')
27-
const [show, setShow] = useState(true)
28-
29-
const button1 = useMemo(
30-
() => (
31-
<button data-tooltip-id="hold" data-tooltip-content="button 1" className="anchor-button">
32-
button 1
33-
</button>
34-
),
35-
[],
36-
)
37-
const button2 = useMemo(
38-
() => (
39-
<button data-tooltip-id="hold" data-tooltip-content="button 2" className="anchor-button">
40-
button 2
41-
</button>
42-
),
43-
[],
44-
)
45-
4626
return (
4727
<main className={styles['main']}>
4828
<button
@@ -113,25 +93,6 @@ function App() {
11393
Tooltip content
11494
</Tooltip>
11595
</section>
116-
<section style={{ marginTop: '100px', marginBottom: '100px' }}>
117-
<div style={{ height: '21px' }}>
118-
{show && <div>{which === '1' ? button1 : button2}</div>}
119-
</div>
120-
<Tooltip id="hold" isOpen holdPositionOnRender>
121-
Hello world!
122-
</Tooltip>
123-
<button
124-
onClick={() => {
125-
setShow(false)
126-
setTimeout(() => {
127-
setShow(true)
128-
}, 1000)
129-
setWhich((w) => (w === '2' ? '1' : '2'))
130-
}}
131-
>
132-
switch
133-
</button>
134-
</section>
13596
<div style={{ display: 'flex', gap: '12px', flexDirection: 'row' }}>
13697
<div>
13798
<div

src/components/Tooltip/Tooltip.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const Tooltip = ({
4242
content,
4343
contentWrapperRef,
4444
isOpen,
45-
holdPositionOnRender,
4645
setIsOpen,
4746
activeAnchor,
4847
setActiveAnchor,
@@ -380,7 +379,7 @@ const Tooltip = ({
380379
let updateTooltipCleanup: null | (() => void) = null
381380
if (closeOnResize) {
382381
window.addEventListener('resize', handleScrollResize)
383-
} else if (activeAnchor && tooltipRef.current && !holdPositionOnRender) {
382+
} else if (activeAnchor && tooltipRef.current) {
384383
updateTooltipCleanup = autoUpdate(
385384
activeAnchor as HTMLElement,
386385
tooltipRef.current as HTMLElement,
@@ -640,7 +639,7 @@ const Tooltip = ({
640639

641640
const canShow = !hidden && content && show && Object.keys(inlineStyles).length > 0
642641

643-
return rendered || (wasShowing.current && holdPositionOnRender) ? (
642+
return rendered ? (
644643
<WrapperElement
645644
id={id}
646645
role="tooltip"

src/components/Tooltip/TooltipTypes.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export interface ITooltip {
8484
style?: CSSProperties
8585
position?: IPosition
8686
isOpen?: boolean
87-
holdPositionOnRender?: boolean
8887
setIsOpen?: (value: boolean) => void
8988
afterShow?: () => void
9089
afterHide?: () => void

src/components/TooltipController/TooltipController.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const TooltipController = ({
4545
position,
4646
isOpen,
4747
disableStyleInjection = false,
48-
holdPositionOnRender,
4948
border,
5049
opacity,
5150
arrowColor,
@@ -334,7 +333,6 @@ const TooltipController = ({
334333
style,
335334
position,
336335
isOpen,
337-
holdPositionOnRender,
338336
border,
339337
opacity,
340338
arrowColor,

src/components/TooltipController/TooltipControllerTypes.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export interface ITooltipController {
6161
position?: IPosition
6262
isOpen?: boolean
6363
disableStyleInjection?: boolean | 'core'
64-
holdPositionOnRender?: boolean
6564
/**
6665
* @description see https://developer.mozilla.org/en-US/docs/Web/CSS/border.
6766
*

0 commit comments

Comments
 (0)