Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/expo-authview-ondismiss-non-dismissible.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/expo': patch
---

Fix `AuthView`'s `onDismiss` never firing on iOS when `isDismissible` is `false`. The callback now runs once the auth flow completes, matching Android, so an app-owned modal or screen wrapping the view can close after sign-in.
13 changes: 8 additions & 5 deletions packages/expo/ios/ClerkAuthNativeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ public class ClerkAuthNativeView: ClerkNativeViewHost {
onAuthEvent(["type": type.rawValue])
}

private func sendDismissIfNeeded() {
// SwiftUI dismissals detach the hosted view without calling UIKit dismiss().
guard currentDismissible, !didSendDismiss else { return }
private func sendDismiss() {
guard !didSendDismiss else { return }
didSendDismiss = true
sendAuthEvent(type: .dismissed)
}
Expand All @@ -56,7 +55,11 @@ public class ClerkAuthNativeView: ClerkNativeViewHost {
}

override func hostedViewDidDetachFromWindow() {
sendDismissIfNeeded()
// SwiftUI dismissals detach the hosted view without calling UIKit dismiss().
// A non-dismissible view never self-dismisses, so a detach there is the host
// tearing the view down rather than a dismissal to report.
guard currentDismissible else { return }
sendDismiss()
}

override public func layoutSubviews() {
Expand Down Expand Up @@ -119,7 +122,7 @@ public class ClerkAuthNativeView: ClerkNativeViewHost {
hostBackAction: hostBackAction,
onEvent: { [weak self] event, _ in
if event == .dismissed {
self?.sendDismissIfNeeded()
self?.sendDismiss()
}
}
)
Expand Down
5 changes: 5 additions & 0 deletions packages/expo/ios/ClerkNativeBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ final class ClerkNativeBridge {

// MARK: - Inline View Creation

@MainActor
func makeAuthViewController(
mode: String,
dismissible: Bool,
Expand All @@ -958,6 +959,10 @@ final class ClerkNativeBridge {
darkTheme: darkTheme,
logoState: logoState,
logoMaxHeight: logoMaxHeight
)
.environment(
\.clerkAuthCompletionAction,
ClerkAuthCompletionAction { onEvent(.dismissed, [:]) }
),
onDismiss: dismissible ? { onEvent(.dismissed, [:]) } : nil
)
Expand Down
Loading