SwiftUI TabView does not work well on orientation change to landscape

Originator:giorashc
Number:rdar://FB9932589 Date Originated:Feb 27, 2022
Status:Open Resolved:
Product:iOS Product Version:15.2
Classification: Reproducible:Always
 
Please describe the issue:
Using a TabView with PageTabViewStyle causes layout issues (wrong page is displayed) when changing orientation to landscape. It seems that the page is changed to a different one once the orientation changes to landscape. 

tested on iOS 15.2 iPhone 11 

Please list the steps you took to reproduce the issue:
- Render the attached view 
- slide a few pages
- rotate device to landscape mode

struct ContentView: View {
    @State private var page = 0
    
    var body: some View {
        TabView(selection: $page) {
            Color.blue.tag(0)
            Color.red.tag(1)
            Color.yellow.tag(2)
            Color.green.tag(3)
            Color.gray.tag(4)
        }
        .tabViewStyle(PageTabViewStyle())
    }
}

What did you expect to happen?
Same page that was rendered in Portrait mode to be rendered in landscape mode after rotation

What actually happened?
Another page was rendered

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!