Skip to content

Commit

Permalink
Save panel position in cache
Browse files Browse the repository at this point in the history
  • Loading branch information
tschumpr committed Sep 4, 2024
1 parent 384c59b commit 6bdb8f9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/client/src/pages/detail/labeling/labelingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ export const LabelingProvider: FC<PropsWithChildren> = ({ children }) => {
const [panelPosition, setPanelPosition] = useState<PanelPosition>("right");
const [panelOpen, setPanelOpen] = useState(false);

const panelPositionStorageName = "labelingPanelPosition";
useLayoutEffect(() => {
const storedPosition = localStorage.getItem("panelPosition") as PanelPosition;
const storedPosition = localStorage.getItem(panelPositionStorageName) as PanelPosition;
if (storedPosition) {
setPanelPosition(storedPosition);
}
}, []);

useEffect(() => {
localStorage.setItem("panelPosition", panelPosition);
localStorage.setItem(panelPositionStorageName, panelPosition);
}, [panelPosition]);

const togglePanel = () => {
Expand Down

0 comments on commit 6bdb8f9

Please sign in to comment.