From 51067e23fd2ebdc782be9015557433639f155880 Mon Sep 17 00:00:00 2001 From: Trey T Date: Mon, 11 May 2026 10:18:04 -0500 Subject: [PATCH] =?UTF-8?q?Fix=20Books=20navigation=20=E2=80=94=20tapping?= =?UTF-8?q?=20a=20book=20no=20longer=20re-pushes=20the=20library?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BookLibraryView is itself pushed from PracticeView's NavigationStack, so the .navigationDestination(for: Book.self) it declared was a non-root registration. Combined with NavigationLink(value: book), that resolved the push to *both* the destination handler and the closure that produced BookLibraryView originally — pushing the chapter list underneath, then re-pushing the library on top. Hitting back popped the library and revealed the chapter list, in the wrong order. Switched both Library→ChapterList and ChapterList→Reader to closure- based NavigationLinks. Destinations attach directly to the link, no type-keyed registry involved. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Views/Practice/Books/BookChapterListView.swift | 4 +++- .../Conjuga/Views/Practice/Books/BookLibraryView.swift | 10 +++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Conjuga/Conjuga/Views/Practice/Books/BookChapterListView.swift b/Conjuga/Conjuga/Views/Practice/Books/BookChapterListView.swift index 8ba7b44..525a72a 100644 --- a/Conjuga/Conjuga/Views/Practice/Books/BookChapterListView.swift +++ b/Conjuga/Conjuga/Views/Practice/Books/BookChapterListView.swift @@ -19,7 +19,9 @@ struct BookChapterListView: View { var body: some View { List { ForEach(allChapters) { chapter in - NavigationLink(value: chapter) { + NavigationLink { + BookReaderView(chapter: chapter) + } label: { HStack(spacing: 12) { Text("\(chapter.number)") .font(.subheadline.weight(.bold).monospacedDigit()) diff --git a/Conjuga/Conjuga/Views/Practice/Books/BookLibraryView.swift b/Conjuga/Conjuga/Views/Practice/Books/BookLibraryView.swift index f9b5d10..a36b1ae 100644 --- a/Conjuga/Conjuga/Views/Practice/Books/BookLibraryView.swift +++ b/Conjuga/Conjuga/Views/Practice/Books/BookLibraryView.swift @@ -17,7 +17,9 @@ struct BookLibraryView: View { ScrollView { LazyVStack(spacing: 12) { ForEach(books) { book in - NavigationLink(value: book) { + NavigationLink { + BookChapterListView(book: book) + } label: { BookCard(book: book) } .tint(.primary) @@ -29,12 +31,6 @@ struct BookLibraryView: View { } .navigationTitle("Books") .navigationBarTitleDisplayMode(.inline) - .navigationDestination(for: Book.self) { book in - BookChapterListView(book: book) - } - .navigationDestination(for: BookChapter.self) { chapter in - BookReaderView(chapter: chapter) - } } }