fix(inbox): use history.replaceState for selection to fix post-refresh clicks

router.replace() triggers a full server navigation cycle in Next.js 15+,
which can stall after a page refresh (no client route cache), preventing
useSearchParams from updating and making inbox items unclickable.

window.history.replaceState() updates the URL synchronously without
triggering server navigation, which is the recommended approach for
URL state management in Next.js 14.1+.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Naiyuan Qing 2026-03-30 17:25:17 +08:00
parent 1a98cac165
commit b4e8dc3769

View file

@ -1,6 +1,6 @@
"use client";
import { useSearchParams, useRouter } from "next/navigation";
import { useSearchParams } from "next/navigation";
import { useDefaultLayout } from "react-resizable-panels";
import { useInboxStore } from "@/features/inbox";
import { IssueDetail, StatusIcon, PriorityIcon } from "@/features/issues/components";
@ -191,14 +191,10 @@ function InboxListItem({
export default function InboxPage() {
const searchParams = useSearchParams();
const router = useRouter();
const selectedId = searchParams.get("id") ?? "";
const setSelectedId = (id: string) => {
if (id) {
router.replace(`/inbox?id=${id}`, { scroll: false });
} else {
router.replace("/inbox", { scroll: false });
}
const url = id ? `/inbox?id=${id}` : "/inbox";
window.history.replaceState(null, "", url);
};
const items = useInboxStore((s) => s.dedupedItems());