crossmate

A collaborative crossword app for iOS
Log | Files | Refs | LICENSE

commit 0b706df02ee4a6a85a65e8c854abbec37f972f2b
parent 42e3f438aaf19f82f59db43f81069ea8800b0a4e
Author: Michael Camilleri <[email protected]>
Date:   Sun, 17 May 2026 09:00:00 +0900

Keep the clue list pinned to the current clue across foregrounding

ClueList centred the current clue only from .onAppear and from .onChange(of:
currentID). When iOS tears down the view backing under memory pressure —
launching a few other apps before returning — SwiftUI rebuilds the view and the
List/ScrollView content offset resets to the top. Neither trigger fires on that
return: the cursor never moved so currentID is unchanged, and .onAppear either
does not re-fire or runs before the list has laid out, so its scrollTo is a
silent no-op. The highlight stayed correct but scrolled off-screen at the top.

Both the sheet List and the sidebar ScrollView now also re-centre on the
current clue when scenePhase becomes .active, mirroring the .onAppear behaviour
(no animation — a silent re-assert, not a jump). This matches the existing
scenePhase handling.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

Diffstat:
MCrossmate/Views/ClueList.swift | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/Crossmate/Views/ClueList.swift b/Crossmate/Views/ClueList.swift @@ -5,6 +5,7 @@ struct ClueList: View { var presentation: Presentation = .sheet @Environment(PlayerPreferences.self) private var preferences @Environment(\.dismiss) private var dismiss + @Environment(\.scenePhase) private var scenePhase enum Presentation { case sheet @@ -80,6 +81,10 @@ struct ClueList: View { proxy.scrollTo(newID, anchor: .center) } } + .onChange(of: scenePhase) { _, newPhase in + guard newPhase == .active, let currentID else { return } + proxy.scrollTo(currentID, anchor: .center) + } } } @@ -128,6 +133,10 @@ struct ClueList: View { proxy.scrollTo(newID, anchor: .center) } } + .onChange(of: scenePhase) { _, newPhase in + guard newPhase == .active, let currentID else { return } + proxy.scrollTo(currentID, anchor: .center) + } } }