Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .changeset/toolbar-tabs-static-navigation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@react-email/ui': patch
'react-email': patch
---

Fixed toolbar tabs not responding on statically built previews when the page was opened with a `toolbar-panel` query param in the URL.
11 changes: 8 additions & 3 deletions packages/ui/src/components/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import * as Tabs from '@radix-ui/react-tabs';
import { LayoutGroup } from 'framer-motion';
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import { usePathname, useSearchParams } from 'next/navigation';
import type { ComponentProps } from 'react';
import * as React from 'react';
import { nicenames } from '../actions/email-validation/caniemail-data';
Expand Down Expand Up @@ -72,7 +72,6 @@ const ToolbarInner = ({
}) => {
const pathname = usePathname();
const searchParams = useSearchParams();
const router = useRouter();

const { hasSetupResendIntegration } = useToolbarContext();

Expand All @@ -89,7 +88,13 @@ const ToolbarInner = ({
} else {
params.set('toolbar-panel', newValue);
}
router.push(`${pathname}?${params.toString()}${location.hash}`);
// Not router.push: on static builds it silently no-ops for query-only
// navigation when the page was loaded with a query param.
window.history.pushState(
null,
'',
`${pathname}?${params.toString()}${location.hash}`,
);
};

const [cachedSpamCheckingResult, setCachedSpamCheckingResult] =
Expand Down
Loading