From 3c260a15978bc1b5ecec611d8090f307977ca8bd Mon Sep 17 00:00:00 2001 From: Ashton Anderson Date: Wed, 25 Feb 2026 16:39:38 -0500 Subject: [PATCH] fix: use mobile analysis layout on narrow tablets --- src/components/Board/MovesContainer.tsx | 5 +++- src/pages/analysis/[...id].tsx | 36 ++++++++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/components/Board/MovesContainer.tsx b/src/components/Board/MovesContainer.tsx index 6032490..94505e3 100644 --- a/src/components/Board/MovesContainer.tsx +++ b/src/components/Board/MovesContainer.tsx @@ -16,6 +16,7 @@ interface Props { disableMoveClicking?: boolean startFromNode?: GameNode restrictNavigationBefore?: GameNode + forceMobileLayout?: boolean } const getMoveClassification = (node: GameNode | null) => { @@ -50,10 +51,12 @@ export const MovesContainer: React.FC< disableMoveClicking = false, startFromNode, restrictNavigationBefore, + forceMobileLayout, embedded = true, heightClass = 'h-48', } = props as Props & { embedded?: boolean; heightClass?: string } - const { isMobile } = useContext(WindowSizeContext) + const { isMobile: viewportIsMobile } = useContext(WindowSizeContext) + const isMobile = forceMobileLayout ?? viewportIsMobile const containerRef = useRef(null) const currentMoveRef = useRef(null) diff --git a/src/pages/analysis/[...id].tsx b/src/pages/analysis/[...id].tsx index 58bee79..42b63df 100644 --- a/src/pages/analysis/[...id].tsx +++ b/src/pages/analysis/[...id].tsx @@ -421,6 +421,17 @@ const Analysis: React.FC = ({ }: Props) => { const { width, height } = useContext(WindowSizeContext) const isMobile = useMemo(() => width > 0 && width <= 670, [width]) + const useMobileStyleAnalysisLayout = useMemo(() => { + if (isMobile) return true + + // Use mobile-style analysis layout for tablet/medium widths to avoid the + // cramped intermediate desktop layout (e.g. iPad and narrow desktop windows). + return width > 670 && width <= 1120 + }, [isMobile, width]) + const isTabletUsingMobileStyleLayout = useMemo( + () => useMobileStyleAnalysisLayout && !isMobile, + [isMobile, useMobileStyleAnalysisLayout], + ) const desktopBoardHeaderStripRef = useRef(null) const desktopBlunderMeterSectionRef = useRef(null) const [desktopMiddleMeasuredHeights, setDesktopMiddleMeasuredHeights] = @@ -430,7 +441,7 @@ const Analysis: React.FC = ({ }) useIsomorphicLayoutEffect(() => { - if (isMobile) return + if (useMobileStyleAnalysisLayout) return const headerEl = desktopBoardHeaderStripRef.current const blunderEl = desktopBlunderMeterSectionRef.current @@ -462,7 +473,7 @@ const Analysis: React.FC = ({ // Intentionally avoid observing live content changes here; the blunder-meter // rows can vary slightly by move, which causes distracting board-size jitter // during arrow-key paging. Re-measure on width changes only. - }, [isMobile, width]) + }, [useMobileStyleAnalysisLayout, width]) const [hoverArrow, setHoverArrow] = useState(null) const [currentSquare, setCurrentSquare] = useState(null) const [promotionFromTo, setPromotionFromTo] = useState< @@ -1185,7 +1196,9 @@ const Analysis: React.FC = ({ >(desktopLeftPanelTabs[0].id) useEffect(() => { - if (isMobile || desktopLeftPanelTab !== 'select-game') return + if (useMobileStyleAnalysisLayout || desktopLeftPanelTab !== 'select-game') { + return + } const keyboardNavigationDisabled = controller.gameAnalysis.progress.isAnalyzing || @@ -1231,7 +1244,7 @@ const Analysis: React.FC = ({ controller.goToPreviousNode, controller.learnFromMistakes.state.isActive, desktopLeftPanelTab, - isMobile, + useMobileStyleAnalysisLayout, ]) const smoothedEvalPosition = useSpring(50, { @@ -1945,11 +1958,18 @@ const Analysis: React.FC = ({ } /> -
+
= ({ ) : null} - {analyzedGame &&
{isMobile ? mobileLayout : desktopLayout}
} + {analyzedGame && ( +
+ {useMobileStyleAnalysisLayout ? mobileLayout : desktopLayout} +
+ )}
{showCustomModal && (