🚸(frontend) reset search on mailbox switch (#743)

When the user switches to anoter mailbox while it is on a search view,
we reset search params and go to to the inbox as it does not make
sens to keep search params on the new mailbox
This commit is contained in:
Jean-Baptiste PENRATH
2026-07-07 08:41:42 +02:00
committed by GitHub
parent c668326896
commit ce2b8f6ab0
@@ -6,6 +6,7 @@ import { useNavigate } from "@tanstack/react-router";
import { useUrlSearchParams } from "@/hooks/use-url-search-params";
import { useLayoutContext } from "@/features/layouts/components/layout-context";
import { MailboxLabels } from "./components/mailbox-labels";
import { MAILBOX_FOLDERS } from "./components/mailbox-list";
import { Group, Panel, Separator, useDefaultLayout } from "react-resizable-panels";
import { MailboxSelector } from "@/features/layouts/components/mailbox-selector";
@@ -31,7 +32,10 @@ export const MailboxPanel = () => {
selectedMailbox={selectedMailbox}
onSelect={(mailboxId) => {
closeLeftPanel();
navigate({ to: '/mailbox/$mailboxId', params: { mailboxId }, search: Object.fromEntries(searchParams) });
const search = searchParams.has("search")
? MAILBOX_FOLDERS()[0].filter
: Object.fromEntries(searchParams);
navigate({ to: '/mailbox/$mailboxId', params: { mailboxId }, search });
}}
/>
</div>