Fix preview-mode logout when opening account settings

In preview mode the dashboard uses an in-memory token store, so the
hard reload from redirectToAccountSettings() wipes the session and
bounces the user to a sign-in page. Soft-navigate via router.push
(app.useNavigate) instead, which preserves the in-memory session.
This commit is contained in:
Bilal Godil 2026-06-25 13:11:08 -07:00
parent c749cf2b62
commit 0e0c3a1bab

View File

@ -88,6 +88,9 @@ export function DashboardUserButton(props: DashboardUserButtonProps) {
function DashboardUserButtonInner(props: DashboardUserButtonProps) {
const user = useUser();
const app = useStackApp();
// Soft-navigate: redirectToAccountSettings() hard-reloads, which wipes preview mode's
// in-memory session and bounces the user to sign-in. router.push keeps the session alive.
const navigate = app.useNavigate();
const showUserInfo = props.showUserInfo === true;
const displayName = user?.displayName ?? user?.primaryEmail ?? "Account";
const iconProps = { size: 16, className: menuIconClassName };
@ -142,7 +145,7 @@ function DashboardUserButtonInner(props: DashboardUserButtonProps) {
{user && (
<DashboardMenuItem
text="Account settings"
onClick={async () => await app.redirectToAccountSettings()}
onClick={() => navigate("/handler/account-settings")}
icon={<UserCircleIcon {...iconProps} />}
/>
)}