Skip to content

Commit 44c14a8

Browse files
committed
fixed bug in ModifiedTable where NullClosure rows (in Drawer) were refreshing to original rows when Delay selector was selected
1 parent a59e995 commit 44c14a8

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

src/components/Editor.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ export const Editor = () => {
127127
];
128128
const [states, setStates] = useState<DraggableStateModel[]>([]);
129129
const [transitions, setTransitions] = useState<TransitionModel[]>([]);
130+
131+
const [nullClosureRows, setNullClosureRows] = useState<RowModel[]>([]);
132+
const [modifiedTableRows, setModifiedTableRows] = useState<RowModel[]>([]);
130133

131134
const [selected, setSelected] = useState<SelectedElementType | null>(null);
132135
const [actionState, setActionState] = useState("Normal");
@@ -672,6 +675,10 @@ export const Editor = () => {
672675
playgroundSize,
673676
stateSize,
674677
setStateSize,
678+
nullClosureRows,
679+
setNullClosureRows,
680+
modifiedTableRows,
681+
setModifiedTableRows,
675682
}}
676683
>
677684
<>

src/components/types/AutomataData.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ export type AutomataData = {
1616
playgroundSize: PlaygroundSize;
1717
stateSize: number;
1818
setStateSize: React.Dispatch<React.SetStateAction<number>>;
19+
nullClosureRows: RowModel[];
20+
setNullClosureRows: React.Dispatch<React.SetStateAction<RowModel[]>>;
21+
modifiedTableRows: RowModel[];
22+
setModifiedTableRows: React.Dispatch<React.SetStateAction<RowModel[]>>;
1923
};

src/features/NfaToDfa.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const NfaToDfa = () => {
9393
};
9494

9595
let modifiedTableProps: ModifiedTableProps = {
96-
rows: nullClosureRows.map((row) => {
96+
rows: dataContext.nullClosureRows.map((row) => {
9797
return {
9898
...row,
9999
...Object.fromEntries(
@@ -110,7 +110,6 @@ export const NfaToDfa = () => {
110110
};
111111
}),
112112
setRows: setModifiedRows,
113-
nullClosureRows: nullClosureRows,
114113
setIsModifiedTransitionTableComplete: setIsModifiedTransitionTableComplete,
115114
};
116115

src/features/components/nfaToDfa/ModifiedTable.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export const ModifiedTable = (props: ModifiedTableProps) => {
187187
dataContext?.rows?.[modifiedTableRowId - 1]?.a
188188
?.split(" ")
189189
?.map((s) =>
190-
props.nullClosureRows
190+
dataContext.nullClosureRows
191191
?.find(
192192
(r) =>
193193
r.state.replaceAll(NullClosureStateId, "") === s
@@ -214,7 +214,7 @@ export const ModifiedTable = (props: ModifiedTableProps) => {
214214
dataContext?.rows?.[modifiedTableRowId - 1]?.b
215215
?.split(" ")
216216
?.map((s) =>
217-
props.nullClosureRows
217+
dataContext.nullClosureRows
218218
?.find(
219219
(r) =>
220220
r.state.replaceAll(NullClosureStateId, "") === s
@@ -308,7 +308,7 @@ export const ModifiedTable = (props: ModifiedTableProps) => {
308308
setOpen,
309309
transitionTableProps: {
310310
rows: GetDrawerTransitionTableRows(
311-
props.nullClosureRows,
311+
dataContext.nullClosureRows,
312312
NullClosureStateId
313313
),
314314
columns: GetDrawerTransitionTableColumns(dataContext.columns, ["a", "b"]),

src/features/components/nfaToDfa/NullClosure.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ export const NullClosure = (props: NullClosureProps) => {
233233
props.setStates(nullClosureStates);
234234
props.setTransitions(nullClosureTransitions);
235235
props.setIsNullClosureTableComplete(true);
236+
dataContext.setNullClosureRows(nullClosureRows);
236237
}
237238

238239
handleUpdateData(

src/features/components/nfaToDfa/props/ModifiedTableProps.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { RowModel } from "../../../../models";
33
export type ModifiedTableProps = {
44
rows: RowModel[];
55
setRows: React.Dispatch<React.SetStateAction<RowModel[]>>;
6-
nullClosureRows: RowModel[];
76
setIsModifiedTransitionTableComplete?: React.Dispatch<
87
React.SetStateAction<boolean>
98
>;

0 commit comments

Comments
 (0)