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;
}
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 }
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,
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,