Skip to content

Commit

Permalink
Fix rootDataAtom in ParamList
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhad6 committed Feb 6, 2024
1 parent 657936c commit fde41ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/atoms/commitSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const selectedCommitIndexStateAtom = atom<number | Promise<number>>(0);
export const selectedCommitIndexAtom = atom(
(get) =>
get(syncLatestAtom) ? get(latestCommitIndexAtom) : get(selectedCommitIndexStateAtom),

(get, set, action: selectCommitIndexAction) => {
if (action.type === "sync") {
if (get(syncLatestAtom)) {
Expand Down
10 changes: 7 additions & 3 deletions src/components/ParamSection/ParamList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ import LeafItemContent from "./LeafItemContent";
import GroupItemContent from "./GroupItemContent";
import CollapseItem from "./CollapseItem";

const rootDataAtom = atom((get) =>
get(editModeAtom) ? get(editedDataAtom) : get(originalDataAtom),
);
const rootDataAtom = atom((get) => {
// Reading the data atoms outside of the conditional ensures that Jotai will register
// both as dependencies, regardless of the result of the conditional.
const editedData = get(editedDataAtom);
const originalData = get(originalDataAtom);
return get(editModeAtom) ? editedData : originalData;
});

const rootListSx = {
borderBottom: 1,
Expand Down

0 comments on commit fde41ea

Please sign in to comment.