I have a NavigationView
based app and I've implemented support for SwiftUI's state restoration using @SceneStorage
to remember which detail view the user has open, as described in Apple's documentation.
It's working correctly if the relevant row in the List
is visible when I launch the app. However, if the relevant row is initially scrolled offscreen, the detail view doesn't get pushed until I scroll down so that the row is onscreen.
I see the same behavior in Apple's sample app, which uses a LazyVGrid
(I had to add some additional data to the products.json
file such that the main content view had to scroll).
Restoring the detail view when the row is offscreen does work in both my app and in Apple's sample app if I replace the List
/ LazyVGrid
with a plain VStack
.
Is this a known limitation of SwiftUI's state restoration with List
and the lazy stack / grid views?