Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FB13341321: AppStorage + Toggle in some case will case some UI render issue with latest OS SDK #444

Open
Kyle-Ye opened this issue Nov 7, 2023 · 0 comments

Comments

@Kyle-Ye
Copy link

Kyle-Ye commented Nov 7, 2023

  • Date: 2023-11-06
  • Resolution: Open
  • Area: SwiftUI
  • OS: iOS 17 & macOS 14
  • Type: Incorrect/Unexpected Behavior
  • Keywords: State, Observable

Description

I suspect the bug was introduced due the Observation support change in SwiftUI. And the bug’s behavior is different on iOS and macOS

(4 toggles: C1T1 C1T2 C2T1 C2T2 - C1T1&C2T1 use the same truth, C1T2&C2T2 use the same truth )

@AppStorage("Test") private var toggle = false
@State private var toggle2 = false

Container {
    Section {
        Toggle("Demo Toggle", isOn: $toggle)
        Toggle("Demo Toggle2", isOn: $toggle2)
    }
}
Container2(sections: [
    Section {
        Toggle("Demo Toggle", isOn: $toggle)
        Toggle("Demo Toggle2", isOn: $toggle2)
    }
])

macOS 14:
C1T1's UI will only be updated at most 1 time if we only tap T1. C2T1 will always reflect the latest value in UI. A tap for T2 will make C1T1's UI up to data.
Tap on C1T2 or C2T2 will update both toggle at the same time. (Expected)
iOS 17
Tap on C2T1 will only update toggle C2T1 while the UI of C1T1 remains the same.
Tap on C1T1 will update both toggle(C1T1 & C2T1) at the same time. (Expected)
Tap on C1T2 or C2T2 will update both toggle at the same time. (Expected)

See full ContentView code in the attachment.
See screen recording and full context here sindresorhus/Settings#117

Files

ContentView.swift.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant