github-sweeper: flagged cells cannot be unflagged via handleCellClick #1002

Closed
opened 2026-08-12 05:51:03 +00:00 by spikerj · 1 comment
Owner

Bug

In GithubSweeperComponent.handleCellClick, the early guard returns when grid[y][x].flagged is true before the right-click / ctrl-click branch that calls toggleFlag.

Effect

Players can flag a cell but cannot unflag it through the click handler (the UI path). toggleFlag itself correctly flips both ways.

Repro (unit)

Pinned by github-sweeper.component.spec.ts — "BUG: handleCellClick cannot unflag".

Fix sketch

Reorder so the flag toggle runs before (or instead of) the flagged early-return, e.g. check button === 2 || ctrlKey first, then bail on revealed/gameOver.

## Bug In `GithubSweeperComponent.handleCellClick`, the early guard returns when `grid[y][x].flagged` is true **before** the right-click / ctrl-click branch that calls `toggleFlag`. ## Effect Players can flag a cell but cannot unflag it through the click handler (the UI path). `toggleFlag` itself correctly flips both ways. ## Repro (unit) Pinned by `github-sweeper.component.spec.ts` — "BUG: handleCellClick cannot unflag". ## Fix sketch Reorder so the flag toggle runs before (or instead of) the flagged early-return, e.g. check `button === 2 || ctrlKey` first, then bail on revealed/gameOver.
Author
Owner

Already present on spikersoft-angular master. handleCellClick runs the right-click/ctrl flag toggle before the flagged early-return, so cells can be unflagged. Closing.

Already present on `spikersoft-angular` `master`. `handleCellClick` runs the right-click/ctrl flag toggle before the flagged early-return, so cells can be unflagged. Closing.
Sign in to join this conversation.