From ece82f79122ffd6f1e3c8fb0d0dac7daae824b92 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sun, 21 Jun 2020 09:19:53 -0700 Subject: [PATCH] Fix square to not be active if occupied Thanks to Scott who noticed yesterday he could tap on an occupied square and get an error message including "Square is already occupied". It's good the server catches that case and sends an error. And it's good the client presentes that cleanly. But the client shouldn't ever even let the user submit a move that the client already know is not legal. In this commit we appropriately set a square to not be active if it is already occupied. This fixes the case described above, and further makes it so that hovering over an occupied square won't even present the user with a cursor suggesting the square is "clickable". --- scribe/scribe.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scribe/scribe.jsx b/scribe/scribe.jsx index d66fc04..ae05690 100644 --- a/scribe/scribe.jsx +++ b/scribe/scribe.jsx @@ -353,10 +353,15 @@ function MiniGrid(props) { function grid_square(j) { const value = props.squares[j]; const last_move = props.last_moves.includes(j); + + /* Even if the grid is active, the square is only active if + * unoccupied. */ + const square_active = (props.active && (value === null)); + return ( props.onClick(j)} /> -- 2.43.0