mirror of
https://github.com/yattee/yattee.git
synced 2026-10-28 23:47:17 +00:00
Keep a section's stack when the sidebar selection changes
In the split-view sidebar layout (macOS, and now iPad and the iPhone Duo), the detail NavigationStack that a selection change replaces writes an empty path through its binding on the way out, so going to another section and back always landed on the section's root. macOS already behaved this way before the router. Only the selected section's stack is on screen and can pop, so path writes for any other section are ignored.
This commit is contained in:
@@ -44,7 +44,15 @@ final class NavigationRouter {
|
||||
let key = item.id
|
||||
return Binding(
|
||||
get: { self.stacks[key] ?? [] },
|
||||
set: { self.stacks[key] = $0 }
|
||||
set: {
|
||||
// Only the selected section's stack is on screen, so only it
|
||||
// edits its path (Back, swipe back). A NavigationSplitView
|
||||
// detail stack that is being replaced on a selection change
|
||||
// writes an empty path on its way out, which would throw
|
||||
// away what the section had pushed.
|
||||
guard key == self.selection.id else { return }
|
||||
self.stacks[key] = $0
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user