Skip to content

Commit 80e69f5

Browse files
authored
fix(channel-web): error reading classList of undefined (#1771)
1 parent bbb0f6e commit 80e69f5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/ui-shared-lite/ToolTip/index.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,18 @@ const ToolTip: FC<ToolTipProps> = ({ childId, children, content, position = 'top
169169
}
170170

171171
setTimeout(() => {
172-
tooltipRef.current.classList.add(style.visible)
172+
tooltipRef.current?.classList.add(style.visible)
173173
if (xClass) {
174-
tooltipRef.current.classList.add(xClass)
174+
tooltipRef.current?.classList.add(xClass)
175175
}
176176
if (yClass) {
177-
tooltipRef.current.classList.add(yClass)
177+
tooltipRef.current?.classList.add(yClass)
178178
}
179179

180-
tooltipRef.current.style.left = inlineStyle.left
181-
tooltipRef.current.style.top = inlineStyle.top
182-
tipRef.current.style.left = tipPos.left
183-
tipRef.current.style.right = tipPos.right
180+
tooltipRef.current?.style.left = inlineStyle.left
181+
tooltipRef.current?.style.top = inlineStyle.top
182+
tipRef.current?.style.left = tipPos.left
183+
tipRef.current?.style.right = tipPos.right
184184
}, hoverOpenDelay || 0)
185185
}
186186
}
@@ -222,7 +222,7 @@ const ToolTip: FC<ToolTipProps> = ({ childId, children, content, position = 'top
222222

223223
const hide = () => {
224224
document.removeEventListener('mousemove', mouseMove)
225-
tooltipRef.current.classList.remove(style.visible)
225+
tooltipRef.current?.classList.remove(style.visible)
226226
const body = document.getElementsByTagName('body')[0]
227227

228228
clearTimeout(timeout.current)

0 commit comments

Comments
 (0)