refactor for useTooltip remove unnecessary as $IntentionalAny
This commit is contained in:
parent
9400aa12a1
commit
79f2424a8a
2 changed files with 5 additions and 8 deletions
|
@ -9,7 +9,6 @@ import {usePrism} from '@theatre/react'
|
|||
import getStudio from '@theatre/studio/getStudio'
|
||||
import {val} from '@theatre/dataverse'
|
||||
import useTooltip from '@theatre/studio/uiComponents/Popover/useTooltip'
|
||||
import type {$IntentionalAny} from '@theatre/shared/utils/types'
|
||||
import BasicTooltip from '@theatre/studio/uiComponents/Popover/BasicTooltip'
|
||||
import ErrorTooltip from '@theatre/studio/uiComponents/Popover/ErrorTooltip'
|
||||
|
||||
|
@ -148,7 +147,7 @@ const OutlinePanel: React.FC<{}> = (props) => {
|
|||
)
|
||||
}, [])
|
||||
|
||||
const [triggerTooltip, triggerButtonRef] = useTooltip(
|
||||
const [triggerTooltip, triggerButtonRef] = useTooltip<HTMLButtonElement>(
|
||||
{enabled: conflicts.length > 0, enterDelay: conflicts.length > 0 ? 0 : 200},
|
||||
() =>
|
||||
conflicts.length > 0 ? (
|
||||
|
@ -167,7 +166,7 @@ const OutlinePanel: React.FC<{}> = (props) => {
|
|||
<TriggerContainer>
|
||||
{triggerTooltip}
|
||||
<TriggerButton
|
||||
ref={triggerButtonRef as $IntentionalAny}
|
||||
ref={triggerButtonRef}
|
||||
data-testid="OutlinePanel-TriggerButton"
|
||||
>
|
||||
<VscListTree />
|
||||
|
|
|
@ -9,7 +9,7 @@ import {useTooltipOpenState} from './TooltipContext'
|
|||
import {PortalContext} from 'reakit'
|
||||
import noop from '@theatre/shared/utils/noop'
|
||||
|
||||
export default function useTooltip(
|
||||
export default function useTooltip<T extends HTMLElement>(
|
||||
opts: {
|
||||
enabled?: boolean
|
||||
enterDelay?: number
|
||||
|
@ -20,15 +20,13 @@ export default function useTooltip(
|
|||
render: () => React.ReactElement,
|
||||
): [
|
||||
node: React.ReactNode,
|
||||
targetRef: MutableRefObject<HTMLElement | SVGElement | null>,
|
||||
targetRef: MutableRefObject<T | null>,
|
||||
isOpen: boolean,
|
||||
] {
|
||||
const enabled = opts.enabled !== false
|
||||
const [isOpen, setIsOpen] = useTooltipOpenState()
|
||||
|
||||
const [targetRef, targetNode] = useRefAndState<
|
||||
HTMLElement | SVGElement | null
|
||||
>(null)
|
||||
const [targetRef, targetNode] = useRefAndState<T | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled) {
|
||||
|
|
Loading…
Reference in a new issue