Skip to content

Commit daf536c

Browse files
fix: stabilize desktop analysis board size while paging
1 parent aadd837 commit daf536c

1 file changed

Lines changed: 13 additions & 27 deletions

File tree

src/pages/analysis/[...id].tsx

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,10 @@ const Analysis: React.FC<Props> = ({
459459
}
460460

461461
updateHeights()
462-
463-
if (typeof ResizeObserver === 'undefined') return
464-
const observer = new ResizeObserver(updateHeights)
465-
if (headerEl) observer.observe(headerEl)
466-
if (blunderEl) observer.observe(blunderEl)
467-
return () => observer.disconnect()
468-
}, [isMobile, width, desktopMiddleMeasuredHeights])
462+
// Intentionally avoid observing live content changes here; the blunder-meter
463+
// rows can vary slightly by move, which causes distracting board-size jitter
464+
// during arrow-key paging. Re-measure on width changes only.
465+
}, [isMobile, width])
469466
const [hoverArrow, setHoverArrow] = useState<DrawShape | null>(null)
470467
const [currentSquare, setCurrentSquare] = useState<Key | null>(null)
471468
const [promotionFromTo, setPromotionFromTo] = useState<
@@ -1062,26 +1059,15 @@ const Analysis: React.FC<Props> = ({
10621059
smoothedMaiaWhiteWinPosition.set(maiaWhiteWinPositionPercent)
10631060
}, [maiaWhiteWinPositionPercent, smoothedMaiaWhiteWinPosition])
10641061

1065-
const desktopMaiaBubbleReservePx = useMemo(() => {
1066-
const useExpandedDesktopBarChrome = width >= 1360
1067-
const text = displayedMaiaWhiteWinBar.label || '--'
1068-
const estimatedWidth = Math.ceil(
1069-
text.length * (useExpandedDesktopBarChrome ? 7 : 6.5) +
1070-
(useExpandedDesktopBarChrome ? 18 : 14),
1071-
)
1072-
return Math.max(useExpandedDesktopBarChrome ? 42 : 36, estimatedWidth)
1073-
}, [displayedMaiaWhiteWinBar.label, width])
1074-
1075-
const desktopEvalBubbleReservePx = useMemo(() => {
1076-
const useExpandedDesktopBarChrome = width >= 1360
1077-
const text = displayedStockfishEvalText || '--'
1078-
// Reserve enough gutter for a centered bubble without forcing the bubble wider.
1079-
const estimatedWidth = Math.ceil(
1080-
text.length * (useExpandedDesktopBarChrome ? 7 : 6.5) +
1081-
(useExpandedDesktopBarChrome ? 18 : 14),
1082-
)
1083-
return Math.max(useExpandedDesktopBarChrome ? 42 : 36, estimatedWidth)
1084-
}, [displayedStockfishEvalText, width])
1062+
const desktopMaiaBubbleReservePx = useMemo(
1063+
() => (width >= 1360 ? 62 : 52),
1064+
[width],
1065+
)
1066+
1067+
const desktopEvalBubbleReservePx = useMemo(
1068+
() => (width >= 1360 ? 56 : 48),
1069+
[width],
1070+
)
10851071

10861072
const desktopEvalGutterWidthPx = useMemo(
10871073
() => desktopEvalBubbleReservePx + 6,

0 commit comments

Comments
 (0)