Popovers icon indicating copy to clipboard operation
Popovers copied to clipboard

iOS 16 issues

Open aheze opened this issue 2 years ago • 0 comments

There seem to be some issues with UIViewRepresentables created multiple times in iOS 16 — see https://stackoverflow.com/questions/73016607/swiftui-button-label-rendered-twice.

Not sure when this started happening, but it seems like Button labels get duplicated now. Take this code:

struct ContentView: View {
    @State var active = false
    var body: some View {
        Button {
            active.toggle()
        } label: {
            Text("Toggle")
                .onChange(of: active) { newValue in
                    print("Active changed to: \(newValue)")
                }
        }
    }
}

It renders fine Button that says Toggle, but check the console:

Active changed to: true Active changed to: true

Why is Active changed to: true printed twice?


This affects WindowReader — the window gets stored in one of the duplicate view copies sometimes, and might not be correct until you scroll, rotate the device, or do a bounds change.

I've filed feedback FB10758896 (SwiftUI - button label rendered twice)

aheze avatar Aug 21 '22 16:08 aheze