Skip to content

Preserve selected algorithm when the grid is rebuilt on resize#25

Merged
Stephan-342B merged 3 commits into
mainfrom
fix/preserve-algorithm-on-resize
Jul 8, 2026
Merged

Preserve selected algorithm when the grid is rebuilt on resize#25
Stephan-342B merged 3 commits into
mainfrom
fix/preserve-algorithm-on-resize

Conversation

@Stephan-342B

Copy link
Copy Markdown
Owner

Bug

After visualizing a run, maximizing / resizing the window loses the configuration and Visualize stops working:

  1. Clicking Visualize reports "Pick an Algorithm!" even though the play button still shows the selected algorithm.
  2. Clicking the same algorithm (e.g. A*) again does nothing — you have to pick a different algorithm and switch back.

Cause

Resizing fires the gridPane layout-bounds listener, which rebuilds the grid and creates a new GridService. Speed is re-applied to the new service, but the selected pathfinding algorithm is not — so the new service's pathAlgorithm is nullMissingAlgorithmException("Pick an Algorithm!").

Bug 2 follows: re-selecting the already-selected menu item doesn't change selectedItemProperty, so no listener fires and the new service never learns the algorithm — hence the "switch away and back" workaround.

Fix

In the resize listener, re-apply the play button's already-selected algorithm to the fresh service (mirroring how updateSpeed is re-applied). This fixes both symptoms — the algorithm survives the rebuild, so Visualize works immediately and no re-selection is needed.

Testing

  • mvn test green (5 tests); mvn compile green.
  • Manual (recommended): select A* + a maze, visualize, maximize, then Visualize again — should run without re-selecting the algorithm.

🤖 Generated with Claude Code

stephan and others added 3 commits July 9, 2026 00:09
Resizing the window (e.g. maximising) fires the gridPane layout-bounds
listener, which rebuilds the grid and creates a fresh GridService. Speed was
re-applied to the new service but the selected pathfinding algorithm was not,
so the new service's algorithm was null: Visualize then reported "Pick an
Algorithm!" even though the play button still showed the selection. Re-picking
the same algorithm did nothing (the menu selection didn't change, so no
listener fired); only switching away and back worked.

Re-apply the button's already-selected algorithm to the new service, mirroring
how speed is re-applied. Fixes both the false "Pick an Algorithm!" and the
dead re-selection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
actions/cache@v2 is now auto-failed by GitHub; bump it (and the equally
deprecated checkout/setup-java/codeql-action) to current majors:
- maven.yml: checkout@v2->v4, setup-java@v2->v4, cache@v2->v4
- codeql.yml: codeql-action init/analyze @v2->v3, checkout@v3->v4

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The project targets Java 21 (java.version=21), but the Maven workflow set up
JDK 17 -> "release version 21 not supported". Bump setup-java to 21. This only
surfaced now that the deprecated actions/cache no longer aborts the run early.

CodeQL still used the unedited template placeholder (autobuild commented out,
a non-existent buildscript.sh run step). Set up JDK 21 and use autobuild so the
Java analysis actually compiles the project.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Stephan-342B Stephan-342B merged commit 86054a6 into main Jul 8, 2026
1 check passed
@Stephan-342B Stephan-342B deleted the fix/preserve-algorithm-on-resize branch July 8, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant