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

Bug fix for loading preferences #113

Merged
merged 3 commits into from
Feb 28, 2025
Merged

Conversation

lam7
Copy link
Contributor

@lam7 lam7 commented Feb 28, 2025

Short description 📝

This Pull Request addresses the issue where the solution in #107 does not resolve the problem with the following code:

extension View {
  func defaultSnapshotSettings() -> some View {
    snapshot(
      precision: 1.0,
      perceptualPrecision: 1.0,
      record: true
    )
  }
}

#Preview {
  Text("")
    .defaultSnapshotSettings()
}

Solution 📦

The solution is to ensure that preferences are read properly. By rendering the view once before calling verifySnapshot, the onPreferenceChange gets called, ensuring that verifySnapshot is invoked afterwards.

@BarredEwe BarredEwe force-pushed the main branch 6 times, most recently from 8084a5f to 26a2d19 Compare February 28, 2025 08:46
@BarredEwe
Copy link
Owner

Hi! Thanks for the fix, it is indeed easier to load the view and get preferences.

@BarredEwe BarredEwe merged commit 4218199 into BarredEwe:main Feb 28, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants