Skip to content

Commit b18a00c

Browse files
authored
fix(desktop): make v2 right sidebar toggle reactive to open state (#3421)
The hover icon swap was silently broken because isOpen was read via a one-shot collections.get() call instead of a live query, so the component never re-rendered when rightSidebarOpen changed.
1 parent 039edf2 commit b18a00c

File tree

1 file changed

+12
-2
lines changed
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/RightSidebarToggle

1 file changed

+12
-2
lines changed

apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/RightSidebarToggle/RightSidebarToggle.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { Tooltip, TooltipContent, TooltipTrigger } from "@superset/ui/tooltip";
2+
import { eq } from "@tanstack/db";
3+
import { useLiveQuery } from "@tanstack/react-db";
24
import {
35
LuPanelRight,
46
LuPanelRightClose,
@@ -9,8 +11,16 @@ import { useCollections } from "renderer/routes/_authenticated/providers/Collect
911

1012
export function RightSidebarToggle({ workspaceId }: { workspaceId: string }) {
1113
const collections = useCollections();
12-
const localState = collections.v2WorkspaceLocalState.get(workspaceId);
13-
const isOpen = localState?.rightSidebarOpen ?? false;
14+
const { data: localStateRows = [] } = useLiveQuery(
15+
(query) =>
16+
query
17+
.from({ v2WorkspaceLocalState: collections.v2WorkspaceLocalState })
18+
.where(({ v2WorkspaceLocalState }) =>
19+
eq(v2WorkspaceLocalState.workspaceId, workspaceId),
20+
),
21+
[collections, workspaceId],
22+
);
23+
const isOpen = localStateRows[0]?.rightSidebarOpen ?? false;
1424

1525
const toggle = () => {
1626
collections.v2WorkspaceLocalState.update(workspaceId, (draft) => {

0 commit comments

Comments
 (0)