From 62281e112485a088be074ed0a79d4197f35fdfc0 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Wed, 14 Jan 2026 22:21:10 -0700 Subject: [PATCH] Fix client answer validation bug and improve scoreboard UX Bug Fix: - Fix stale closure bug in client answer validation where correct answers were sometimes marked incorrect. The issue occurred when players answered quickly after a question started - React's async state updates meant currentCorrectShape could hold the previous question's value. Added currentCorrectShapeRef to ensure the latest value is always used. Scoreboard Improvements: - Unified desktop/mobile layout: avatar, name, and points on first line; progress bar on second line; bonus pills on third line - Removed 5-player limit to show all players - Added vertical scrolling when player list exceeds viewport - Fixed layout to prevent content overflow issues --- components/Scoreboard.tsx | 48 +++++++++++++++----------------------- hooks/useGame.ts | 49 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 31 deletions(-) diff --git a/components/Scoreboard.tsx b/components/Scoreboard.tsx index 6743bdc..e44f4bf 100644 --- a/components/Scoreboard.tsx +++ b/components/Scoreboard.tsx @@ -93,39 +93,29 @@ const PlayerRow: React.FC = ({ player, index, maxScore }) => { initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }} transition={{ delay: baseDelay, duration: 0.4 }} - className="flex flex-col md:flex-row md:items-center gap-2 md:gap-4 py-3" + className="flex flex-col gap-2 py-3" > -
+
{player.displayName}
-
- - - -
+ + +
-
-
- -
- -
- - - -
+
+
-
+
{breakdown === null && ( = ({ players, onNext, isHost, ...p, displayName: p.id === currentPlayerId ? `${p.name} (You)` : p.name })); - const sortedPlayers = [...playersWithDisplayName].sort((a, b) => b.score - a.score).slice(0, 5); + const sortedPlayers = [...playersWithDisplayName].sort((a, b) => b.score - a.score); const maxScore = Math.max(...sortedPlayers.map(p => p.score), 1); return ( -
-
+
+

Scoreboard

-
+
{sortedPlayers.map((player, index) => ( @@ -217,7 +207,7 @@ export const Scoreboard: React.FC = ({ players, onNext, isHost,
-
+
{isHost ? (