clerk/clerk-ios

Empty sheet remains in view after Sign out

Closed this issue · 2 comments

I am doing sign out and empty sheet remains in view like this:

IMG_2503

This is the error I get in Xcode:

List failed to visit cell content, returning an empty cell. - SwiftUI/UICollectionViewListCoordinator.swift:373 - please file a bug report.

It started to malfunction today and it was working well previously.
This is the code structure for replication:

ContentView.swift

var body: some View {
            VStack {
                if clerk.session != nil {
                    TabView {
                        HomeView().tabItem { Label("Home", systemImage: "house") }
                        NewsView().tabItem{ Label("News", systemImage: "newspaper") }
                        MeView().tabItem{ Label("Me", systemImage: "person") }
                    }
                } else {
                    Spacer()
                    AdaptiveImage(light: Image("BlackLogo"), dark: Image("WhiteLogo"))
                    Spacer()
                    Text("Start here")
                    UserButton()
                }
            }
    }

Also I am using:
Xcode Version 15.0.1 (15A507)
and building on:
iOS 17.0

Hey @semirteskeredzic, thanks for the report. While Clerk prebuilt views are still very much a work in progress and subject to change, I think I see what's going on here.

Based on your screenshot, I'm guessing you have another UserButton somewhere else? Maybe in your MeView? At the moment, the UserButton isn't meant to be conditionally shown/hidden based on the presence of a session. The UserButton is intended as a view that remains on screen between sign in and sign out. It functions as the sign in button when there isn't a session, and the account switcher / user profile when there is one. In your implementation it looks like you might be using it as a sign in button and separate sign out button.

I think what's happening is you are removing the parent view of the sheet (the UserButton) before it has a chance to dismiss the sheet. Try moving your UserButton outside your conditions of a session being present, and let me know if that fixes it.

Either way, thanks for the report. We'll take this use case into consideration as we continue working on Clerk's prebuilt views.