mirror of
https://github.com/runbear-io/beardrive.git
synced 2026-08-25 08:08:08 +02:00
fix(web): Dashboard menu dead after opening a panel on the insights route
Panels are not routes: navigating to the already-current /insights URL never changes pathname, so the route-change effect couldn't close the open panel. Menu Dashboard (and the ⋯ Insights entry) now close the panel explicitly. Regression spec added; 46/46. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbiaaVM2ACxeRi8ySG9ybc
This commit is contained in:
co-authored by
Claude Fable 5
parent
7a41a9e5b6
commit
e894f4ced9
@@ -176,4 +176,9 @@ test("project menu: Dashboard, Installation, Settings", async ({ page }) => {
|
||||
await page.click("#nav-settings");
|
||||
await expect(page.locator("#crumb")).toHaveText("Project settings");
|
||||
await expect(page.locator(".project-settings h2")).toHaveText("wiki");
|
||||
// Regression: from a panel, Dashboard must work even when the URL is
|
||||
// already /insights (same-path navigation can't rely on route change).
|
||||
await page.click("#nav-dashboard");
|
||||
await expect(page.locator(".insights .in-title")).toContainText("Knowledge insights");
|
||||
await expect(page.locator("#nav-dashboard")).toHaveClass(/active/);
|
||||
});
|
||||
|
||||
@@ -40,6 +40,7 @@ export default function Browser(props: {
|
||||
// touching the URL — matching the classic app, where they were never
|
||||
// routes. Any navigation closes them (the caller owns that state).
|
||||
panel?: { crumb: string; body: ReactNode } | null;
|
||||
onClosePanel?: () => void; // panels are not routes: same-path navigation needs an explicit close
|
||||
}) {
|
||||
const { config, apiBase, route, hub, project } = props;
|
||||
const routeKey = useLocationPath(); // scroll memo key, one slot per URL
|
||||
@@ -394,7 +395,10 @@ export default function Browser(props: {
|
||||
{props.canInsights && (
|
||||
<button
|
||||
className="more-item"
|
||||
onClick={() => navigate(urlForView("insights", project?.id, path))}
|
||||
onClick={() => {
|
||||
props.onClosePanel?.();
|
||||
navigate(urlForView("insights", project?.id, path));
|
||||
}}
|
||||
>
|
||||
Insights
|
||||
</button>
|
||||
|
||||
@@ -191,6 +191,10 @@ export default function HubApp({ config }: { config: ServerConfig }) {
|
||||
? "dashboard"
|
||||
: null,
|
||||
onDashboard: () => {
|
||||
// Explicitly close any panel: navigating to the SAME url
|
||||
// (already on /insights) doesn't change pathname, so the
|
||||
// route-change effect can't do it.
|
||||
setPanel(null);
|
||||
navigate(urlForView("insights", current.id));
|
||||
closeSidebarOnMobile();
|
||||
},
|
||||
@@ -208,6 +212,7 @@ export default function HubApp({ config }: { config: ServerConfig }) {
|
||||
orgBar: accountBar,
|
||||
}}
|
||||
panel={activePanel}
|
||||
onClosePanel={() => setPanel(null)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>BearDrive</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🐻</text></svg>">
|
||||
<script type="module" crossorigin src="/assets/index-BZW-lolE.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DDdhKsd5.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-C5jjBsTc.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user