File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import React from 'react'
2+ import { createPortal } from 'react-dom'
23import { ColorSanMapping } from 'src/types'
34
45interface MoveTooltipProps {
@@ -22,14 +23,14 @@ export const MoveTooltip: React.FC<MoveTooltipProps> = ({
2223 position,
2324 isVisible = true ,
2425} ) => {
25- if ( ! isVisible || ! position ) return null
26+ if ( ! isVisible || ! position || typeof window === 'undefined' ) return null
2627
2728 const san = colorSanMapping [ move ] ?. san ?? move
2829 const color = colorSanMapping [ move ] ?. color ?? '#fff'
2930
30- return (
31+ const tooltipContent = (
3132 < div
32- className = "pointer-events-none fixed z-50 flex w-auto min-w-[12rem] flex-col overflow-hidden rounded-lg border border-white/30 bg-background-1 backdrop-blur-sm"
33+ className = "pointer-events-none fixed z-50 flex w-auto min-w-[12rem] flex-col overflow-hidden rounded-lg border border-white/30 bg-background-1 text-primary backdrop-blur-sm"
3334 style = { {
3435 left : position . x + 15 ,
3536 top : position . y - 10 ,
@@ -83,4 +84,6 @@ export const MoveTooltip: React.FC<MoveTooltipProps> = ({
8384 </ div >
8485 </ div >
8586 )
87+
88+ return createPortal ( tooltipContent , document . body )
8689}
You can’t perform that action at this time.
0 commit comments