From d569ab5c72ae30e4a5ba998ea8426ef8ab7c8b93 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 7 Mar 2026 08:53:12 -0500 Subject: [PATCH] letterrip: Don't bring up modal for selecting blank tile when first clicking it Instead, just select the tile on first click, and then bring up the selection modoal on the second click, (either when selecting the destination cell for movement or deselecting it). This is consistent behavior with what the user will have first seen when moving the blank from the rack to the board, and now means that the user can use click-to-select/click-to-move to move a blank tile from one board square to another, (which was impossible prior to this commit). --- letterrip/letterrip.jsx | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/letterrip/letterrip.jsx b/letterrip/letterrip.jsx index 8489006..a6bc234 100644 --- a/letterrip/letterrip.jsx +++ b/letterrip/letterrip.jsx @@ -730,9 +730,15 @@ class Game extends React.Component { const sel = this.state.selected; const cell = this.state.grid[grid_key]; - /* If tapping the already-selected grid tile, deselect. */ + /* If tapping the already-selected grid tile, deselect it. + * For blanks, also offer to reassign the letter. */ if (sel && sel.from === "grid" && sel.grid_key === grid_key) { - this.setState({ selected: null }); + const updates = { selected: null }; + if (cell && cell.isBlank) { + const [r, c] = grid_key.split(",").map(Number); + updates.blank_pending = { r, c, tileIndex: cell.tileIndex, reassign: true }; + } + this.setState(updates); return; } @@ -747,15 +753,6 @@ class Game extends React.Component { return; } - /* If a blank is tapped on the grid, allow reassigning its letter. */ - if (cell && cell.isBlank) { - const [r, c] = grid_key.split(",").map(Number); - this.setState({ - blank_pending: { r, c, tileIndex: cell.tileIndex, reassign: true } - }); - return; - } - /* Select this grid tile. */ this.setState({ selected: { from: "grid", grid_key, tile_index: cell.tileIndex } @@ -806,8 +803,8 @@ class Game extends React.Component { delete new_grid[sel.grid_key]; } - /* Blank tile that hasn't been assigned a letter — show modal. */ - if (is_blank && !(sel.from === "grid" && this.state.grid[sel.grid_key] && this.state.grid[sel.grid_key].letter)) { + /* Blank tile — always show the modal so the user can pick a letter. */ + if (is_blank) { this.setState({ grid: new_grid, rack: new_rack, @@ -817,12 +814,7 @@ class Game extends React.Component { return; } - /* Preserve existing letter assignment for blanks being moved. */ - const existing = sel.from === "grid" ? this.state.grid[sel.grid_key] : null; - const letter = existing ? existing.letter : tile_char; - const isBlank = existing ? existing.isBlank : is_blank; - - new_grid[grid_key] = { letter, tileIndex: tile_index, isBlank }; + new_grid[grid_key] = { letter: tile_char, tileIndex: tile_index, isBlank: false }; this.setState({ grid: new_grid, -- 2.45.2