fix(ui): turn navigator no-op when re-selecting the on-screen turn #57
Reference in New Issue
Block a user
Delete Branch "feature/issue-45-turn-navigator-noop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
In the header turn navigator, clicking the current-turn row of the
dropdown while it is already the turn on screen routed through
returnToCurrent()→viewTurn(currentTurn), which re-fetches the livereport and flips the view through
loading. At turn 0 the only rowis the live turn, so opening the dropdown and clicking it always fired
a pointless backend round-trip and a redraw of the identical snapshot.
Fix
goToTurn()now guards against re-selecting the turn already on screen(
turn === viewedTurn): it closes the popover and stops. The guard iswritten against
viewedTurnrather than special-casing turn 0, so italso drops the redundant re-fetch when re-picking a history turn you are
already viewing. Leaving history is unaffected — there the viewed turn
differs from the target, so
returnToCurrent()/viewTurn(N)still run.Tests
ui/frontend/tests/turn-navigator.test.ts: two regression tests — thelive row at turn 0 is a no-op (neither
viewTurnnorreturnToCurrentfires, popover still closes), and re-selecting the already-viewed
history row is a no-op.
svelte-checkclean (0 errors / 0 warnings).
Docs
ui/docs/navigation.mdand the component header comment updated todescribe the no-op.
Closes #45