Skip to content

Commit

Permalink
fix: can't interact with diagram after switching
Browse files Browse the repository at this point in the history
previously, if viewing a claim tree or criteria table, then
switching to another topic (or resetting playground), the navigation
store would still assume the topic diagram is in the background.

solution is just to reset navigation store on topic load.
  • Loading branch information
keyserj committed Jan 10, 2024
1 parent db40b90 commit 5f4c5e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/web/common/event.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createNanoEvents } from "nanoevents";

import { Node } from "../topic/utils/graph";
import { resetNavigation } from "../view/navigateStore";

interface Events {
addNode: (node: Node) => void;
Expand All @@ -9,3 +10,8 @@ interface Events {
}

export const emitter = createNanoEvents<Events>();

// could go elsewhere but don't want to put into Diagram components because they usually aren't rendered before loading
emitter.on("loadedTopicData", () => {
resetNavigation();
});
5 changes: 5 additions & 0 deletions src/web/view/navigateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,8 @@ export const goBack = () => {
export const goForward = () => {
useNavigateStore.temporal.getState().redo();
};

export const resetNavigation = () => {
useNavigateStore.setState(initialState);
useNavigateStore.temporal.getState().clear();
};

0 comments on commit 5f4c5e4

Please sign in to comment.