Skip to content

fix(BC-173): profile ui updates properly after logging out#20

Open
mellobacon wants to merge 2 commits intomainfrom
mellobacon/bc-173
Open

fix(BC-173): profile ui updates properly after logging out#20
mellobacon wants to merge 2 commits intomainfrom
mellobacon/bc-173

Conversation

@mellobacon
Copy link
Copy Markdown
Contributor

signs out and navigates back to the homepage

@linear
Copy link
Copy Markdown

linear bot commented Mar 31, 2026

@mellobacon mellobacon linked an issue Mar 31, 2026 that may be closed by this pull request
@Duxez
Copy link
Copy Markdown
Member

Duxez commented Mar 31, 2026

Do we really want to navigate back to the home page rather than staying on the profile page of the user and just not showing the edit button?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the user menu logout behavior so signing out also navigates the user back to the homepage, ensuring the UI reflects the logged-out state immediately.

Changes:

  • Make the “SIGN OUT” dropdown item render as a router link to / while triggering authClient.signOut().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 74 to 78
<DropdownMenuItem
className="font-mono text-xs font-bold tracking-widest uppercase text-destructive"
onClick={() => authClient.signOut()}
render={<Link to="/" />}
>
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

authClient.signOut() is likely async (it’s invoked with void elsewhere). With render={<Link to="/" />} the navigation may occur before sign-out completes, and any rejection from signOut() is currently unhandled. Consider handling the promise (e.g., void/await) and triggering navigation only after sign-out succeeds (using router navigation in the click handler rather than rendering as a Link), optionally showing an error if sign-out fails.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@mellobacon Ignore the comment about async here, fire-and-forget is the typical pattern for async handlers in click events and because the AppHeader is always mounted, the navigation to / won't stop the signOut from continuing

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That being said, a better way to do this would be to use better-auth's fetchOptions so that the redirect is within the auth lifecycle

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Image

In our example here, we'd just use the useNavigate hook from tanstack router to await the nav to / in the success of fetchOptions

@josh-complex
Copy link
Copy Markdown
Collaborator

Do we really want to navigate back to the home page rather than staying on the profile page of the user and just not showing the edit button?

@Duxez this is a pretty typical pattern, but another option is to instead invalidate the current router to reload the current route which would take them out of edit but keep them on the profile

@Duxez
Copy link
Copy Markdown
Member

Duxez commented Mar 31, 2026

@Duxez this is a pretty typical pattern, but another option is to instead invalidate the current router to reload the current route which would take them out of edit but keep them on the profile

@josh-complex I know it's typical, I also hate it lol

@josh-complex
Copy link
Copy Markdown
Collaborator

@josh-complex I know it's typical, I also hate it lol

Haha bet, then @mellobacon lets just call tanstack's useRouter hook and invalidate the router to reload the current route instead of routing to home in the fetchOptions success

@josh-complex
Copy link
Copy Markdown
Collaborator

Oh sorry actually, the recommended way with modern tanstack router is by using the relative paths, so stick with my earlier comment about using useNavigate https://tanstack.com/router/latest/docs/guide/navigation#special-relative-paths--and-

@mellobacon
Copy link
Copy Markdown
Contributor Author

Oh sorry actually, the recommended way with modern tanstack router is by using the relative paths, so stick with my earlier comment about using useNavigate https://tanstack.com/router/latest/docs/guide/navigation#special-relative-paths--and-

@josh-complex So do we still want it to navigate to the homepage? Or just refresh the current page?

@Duxez
Copy link
Copy Markdown
Member

Duxez commented Apr 1, 2026

Oh sorry actually, the recommended way with modern tanstack router is by using the relative paths, so stick with my earlier comment about using useNavigate https://tanstack.com/router/latest/docs/guide/navigation#special-relative-paths--and-

@josh-complex So do we still want it to navigate to the homepage? Or just refresh the current page?

Well, josh said do it my way, but honestly that'll just become a hassle to fix once admin panels come in so just navigate home in the way josh showed tbh. It's logical for admin views to be navigated away from after logout.

I just don't like it when it also happens on public pages lol

navigates back to the homepage

Signed-off-by: mello <mellodev@outlook.com>
page refreshes on logout

Signed-off-by: mello <mellodev@outlook.com>
@oliverbooth oliverbooth requested a review from a team April 4, 2026 07:21
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.

Signing out keeps editing available

4 participants