Skip to content

Fix UIKit trait collection change handling#916

Merged
Kyle-Ye merged 1 commit into
mainfrom
bugfix/traitCollectionDidChange
Jun 22, 2026
Merged

Fix UIKit trait collection change handling#916
Kyle-Ye merged 1 commit into
mainfrom
bugfix/traitCollectionDidChange

Conversation

@Kyle-Ye

@Kyle-Ye Kyle-Ye commented Jun 21, 2026

Copy link
Copy Markdown
Member

Summary

  • Refresh the UIKit event bridge when the hosting view's user interface idiom changes.
  • Invalidate the hosting environment after trait collection changes.
  • Wire UIKitEventBindingBridge through AnyUIHostingView/EventBindingBridge so the bridge can update CarPlay touch handling.

@github-actions github-actions Bot added area: event-gesture Events, gestures, tracing, or interaction plumbing. area: hosting-bridge SwiftUI bridge, UIHosting/NSHosting, representables, and platform host views. platform: iOS iOS-specific behavior or support. type: bug Something is not working correctly. labels Jun 21, 2026
@Kyle-Ye Kyle-Ye marked this pull request as ready for review June 21, 2026 16:45
@augmentcode

augmentcode Bot commented Jun 21, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR improves UIKit trait-collection change handling for hosted SwiftUI content.

Changes:

  • Introduces a `UIKitEventBindingBridge` subclass of `EventBindingBridge` and threads it through `_UIHostingView`/`AnyUIHostingView`.
  • Creates and stores an `eventBridge` on `_UIHostingView` during initialization.
  • On `traitCollectionDidChange`, refreshes event-bridge behavior when the user-interface idiom changes (e.g. enabling CarPlay-specific touch handling).
  • Invalidates hosting environment properties after trait changes to ensure environment values are recomputed.
Technical Notes: Adds a CarPlay path that constrains a gesture recognizer’s `allowedTouchTypes` to direct touches when applicable.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

extension _UIHostingView: AnyUIHostingView {
package var debugName: String? {
// TODO: UIHostingViewDebugOptions
_openSwiftUIUnimplementedWarning()

@augmentcode augmentcode Bot Jun 21, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView+Extension.swift:415 — Calling _openSwiftUIUnimplementedWarning() inside debugName can spam logs and can even fatalError under OPENSWIFTUI_DEVELOPMENT when UIHostingViewDebugLayer.name is queried repeatedly by CoreAnimation. Consider returning nil without warning until UIHostingViewDebugOptions is implemented.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 25.98%. Comparing base (bfad60c) to head (10cf869).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #916       +/-   ##
===========================================
+ Coverage   13.81%   25.98%   +12.16%     
===========================================
  Files         676      719       +43     
  Lines       44380    50668     +6288     
===========================================
+ Hits         6132    13165     +7033     
+ Misses      38248    37503      -745     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kyle-Ye Kyle-Ye merged commit af1b689 into main Jun 22, 2026
9 checks passed
@Kyle-Ye Kyle-Ye deleted the bugfix/traitCollectionDidChange branch June 22, 2026 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: event-gesture Events, gestures, tracing, or interaction plumbing. area: hosting-bridge SwiftUI bridge, UIHosting/NSHosting, representables, and platform host views. platform: iOS iOS-specific behavior or support. type: bug Something is not working correctly.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant