I'm pursuing a design that necessitates a dual app architecture — using a NavigationStack
for compact-sized screens, and a NavigationSplitView
for regular-sized screens.
I've encountered what might be a bug in NavigationSplitView
on iPadOS 17.x. Or perhaps it's a mistake in my code.
When navigating into nested views (relying on NavigationPath
), everything works fine... until I background the app on iPad.
At this point, the navigation stack appears to collapse in the NavigationSplitView
detail area — merging the parent and child views.
Adding to the mystery... I can reproduce this bug on iPadOS 17.x. But the problem goes away when running on iPadOS 18.x beta.
Key questions:
- Is there a problem in my code?
- Should I file a feedback with the Apple SwiftUI team?
- If iPadOS 18.x fixes this bug, can I expect a SwiftUI fix to be back-ported to 17.x or earlier?
Steps to reproduce:
- Run my sample code on iPadOS simulator.
- Navigate to select a color, and then a shape.
- Put the app into the background (e.g., go to Home Screen).
- Return to app.
What you can expect:
When running on iPadOS 17.x, you'll see that the two most recent views in the stack have merged (meaning the title has changed, and the "back" button has disappeared).
On iPadOS 18.x, you'll see that everything is working fine (title isn't changed, and back button remains available).
Hey @p98 ,
Sorry for the delay, would you mind mentioning me with the "@" sign, it makes it easier for me to see when there's a response :)
Ah I see what the issue is now. This is a known issue with the toolbar item disappearing in the content view of a NavigationSplitView
in 11inch iPads. Please file a bug report at https://feedbackassistant.apple.com and post the FB number here. You'll be able to follow the status of it if you do this.
Also, you mentioned
when trying to add .searchable() with its own NavigationStack to the root-level sidebar section of NavigationSplitView. It seems that NavigationStack isn't something that SwiftUI wants in that part of the NavigationSplitView.
Although you shouldn't add NavigationStack
, you can definitely add the .searchable
modifier here. Just add it to the bottom of your NavigationSplitView
and you can control the placement yourself to be in the sidebar, as shown here. https://developer.apple.com/documentation/swiftui/adding-a-search-interface-to-your-app#Control-the-placement-programmatically