Skip to content

Commit 59c9d07

Browse files
chore: remove deprecated tooltip provider
1 parent b1da496 commit 59c9d07

File tree

8 files changed

+11
-230
lines changed

8 files changed

+11
-230
lines changed

jest.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ export default {
2525
// dev stuff
2626
'!src/*',
2727
'!src/**/*.d.ts',
28-
// deprecated
29-
'!src/components/TooltipProvider/*',
3028
],
3129

3230
// The directory where Jest should output its coverage files

src/components/Tooltip/Tooltip.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
clearTimeoutRef,
1212
} from 'utils'
1313
import type { IComputedPosition } from 'utils'
14-
import { useTooltip } from 'components/TooltipProvider'
1514
import coreStyles from './core-styles.module.css'
1615
import styles from './styles.module.css'
1716
import type {
@@ -86,10 +85,6 @@ const Tooltip = ({
8685
)
8786
const wasShowing = useRef(false)
8887
const lastFloatPosition = useRef<IPosition | null>(null)
89-
/**
90-
* @todo Remove this in a future version (provider/wrapper method is deprecated)
91-
*/
92-
const { anchorRefs, setActiveAnchor: setProviderActiveAnchor } = useTooltip(id)
9388
const hoveringTooltip = useRef(false)
9489
const [anchorsBySelect, setAnchorsBySelect] = useState<HTMLElement[]>([])
9590
const mounted = useRef(false)
@@ -291,7 +286,6 @@ const Tooltip = ({
291286
* at the same time the tooltip gets triggered
292287
*/
293288
setActiveAnchor(null)
294-
setProviderActiveAnchor({ current: null })
295289
return
296290
}
297291
if (delayShow) {
@@ -300,7 +294,6 @@ const Tooltip = ({
300294
handleShow(true)
301295
}
302296
setActiveAnchor(target)
303-
setProviderActiveAnchor({ current: target })
304297

305298
clearTimeoutRef(tooltipHideDelayTimerRef)
306299
}
@@ -456,15 +449,15 @@ const Tooltip = ({
456449
])
457450

458451
useEffect(() => {
459-
const elementRefs = new Set(anchorRefs)
452+
const elementRefs = new Set<HTMLElement>()
460453

461454
anchorsBySelect.forEach((anchor) => {
462-
elementRefs.add({ current: anchor })
455+
elementRefs.add(anchor)
463456
})
464457

465458
const anchorById = document.querySelector<HTMLElement>(`[id='${anchorId}']`)
466459
if (anchorById) {
467-
elementRefs.add({ current: anchorById })
460+
elementRefs.add(anchorById)
468461
}
469462

470463
const handleScrollResize = () => {
@@ -586,7 +579,7 @@ const Tooltip = ({
586579

587580
enabledEvents.forEach(({ event, listener }) => {
588581
elementRefs.forEach((ref) => {
589-
ref.current?.addEventListener(event, listener)
582+
ref.addEventListener(event, listener)
590583
})
591584
})
592585

@@ -613,7 +606,7 @@ const Tooltip = ({
613606
}
614607
enabledEvents.forEach(({ event, listener }) => {
615608
elementRefs.forEach((ref) => {
616-
ref.current?.removeEventListener(event, listener)
609+
ref.removeEventListener(event, listener)
617610
})
618611
})
619612
}
@@ -625,7 +618,6 @@ const Tooltip = ({
625618
activeAnchor,
626619
updateTooltipPosition,
627620
rendered,
628-
anchorRefs,
629621
anchorsBySelect,
630622
// the effect uses the `actual*Events` objects, but this should work
631623
openEvents,

src/components/TooltipController/TooltipController.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import type {
1111
ChildrenType,
1212
TooltipRefProps,
1313
} from 'components/Tooltip/TooltipTypes'
14-
import { useTooltip } from 'components/TooltipProvider'
1514
import { cssSupports } from 'utils'
1615
import clsx from 'clsx'
1716
import type { ITooltipController } from './TooltipControllerTypes'
@@ -77,10 +76,6 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
7776
const [tooltipClassName, setTooltipClassName] = useState<string | null>(null)
7877
const [activeAnchor, setActiveAnchor] = useState<HTMLElement | null>(null)
7978
const styleInjectionRef = useRef(disableStyleInjection)
80-
/**
81-
* @todo Remove this in a future version (provider/wrapper method is deprecated)
82-
*/
83-
const { anchorRefs, activeAnchor: providerActiveAnchor } = useTooltip(id)
8479

8580
const getDataAttributesFromAnchorElement = (elementReference: HTMLElement) => {
8681
const dataAttributes = elementReference?.getAttributeNames().reduce((acc, name) => {
@@ -206,7 +201,7 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
206201
}, [])
207202

208203
useEffect(() => {
209-
const elementRefs = new Set(anchorRefs)
204+
const elementRefs = new Set<HTMLElement>()
210205

211206
let selector = anchorSelect
212207
if (!selector && id) {
@@ -216,7 +211,7 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
216211
try {
217212
const anchorsBySelect = document.querySelectorAll<HTMLElement>(selector)
218213
anchorsBySelect.forEach((anchor) => {
219-
elementRefs.add({ current: anchor })
214+
elementRefs.add(anchor)
220215
})
221216
} catch {
222217
/* c8 ignore start */
@@ -230,14 +225,14 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
230225

231226
const anchorById = document.querySelector<HTMLElement>(`[id='${anchorId}']`)
232227
if (anchorById) {
233-
elementRefs.add({ current: anchorById })
228+
elementRefs.add(anchorById)
234229
}
235230

236231
if (!elementRefs.size) {
237232
return () => null
238233
}
239234

240-
const anchorElement = activeAnchor ?? anchorById ?? providerActiveAnchor.current
235+
const anchorElement = activeAnchor ?? anchorById
241236

242237
const observerCallback: MutationCallback = (mutationList) => {
243238
mutationList.forEach((mutation) => {
@@ -272,7 +267,7 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
272267
// Remove the observer when the tooltip is destroyed
273268
observer.disconnect()
274269
}
275-
}, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect])
270+
}, [activeAnchor, anchorId, anchorSelect])
276271

277272
useEffect(() => {
278273
/* c8 ignore start */
@@ -358,7 +353,7 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
358353
afterShow,
359354
afterHide,
360355
activeAnchor,
361-
setActiveAnchor: (anchor: HTMLElement | null) => setActiveAnchor(anchor),
356+
setActiveAnchor,
362357
role,
363358
}
364359

src/components/TooltipProvider/TooltipProvider.tsx

Lines changed: 0 additions & 106 deletions
This file was deleted.

src/components/TooltipProvider/TooltipProviderTypes.d.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/components/TooltipProvider/TooltipWrapper.tsx

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/components/TooltipProvider/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import type {
1515
TooltipRefProps,
1616
} from './components/Tooltip/TooltipTypes'
1717
import type { ITooltipController } from './components/TooltipController/TooltipControllerTypes'
18-
import type { ITooltipWrapper } from './components/TooltipProvider/TooltipProviderTypes'
1918

2019
// those content will be replaced in build time with the `react-tooltip.css` builded content
2120
const TooltipCoreStyles = 'react-tooltip-core-css-placeholder'
@@ -35,7 +34,6 @@ if (typeof window !== 'undefined') {
3534
}
3635

3736
export { TooltipController as Tooltip } from './components/TooltipController'
38-
export { TooltipProvider, TooltipWrapper } from './components/TooltipProvider'
3937
export type {
4038
ChildrenType,
4139
DataAttribute,
@@ -45,7 +43,6 @@ export type {
4543
VariantType,
4644
WrapperType,
4745
ITooltipController as ITooltip,
48-
ITooltipWrapper,
4946
IPosition,
5047
Middleware,
5148
TooltipRefProps,

0 commit comments

Comments
 (0)