Skip to content

Commit 4e47969

Browse files
committed
fixed bug where values of a saved row in transition table weren't being sorted
1 parent b09e6fe commit 4e47969

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/pages/Editor.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ export const Editor = () => {
243243
?.trim()
244244
?.split(" ")
245245
?.filter((s) => s !== "")
246+
?.sort()
246247
)
247248
)?.join(" "))
248249
);
@@ -286,20 +287,20 @@ export const Editor = () => {
286287
let errorWhileSavingRow = false;
287288
setRows((prev) => {
288289
let availableStateValues = prev
289-
.map((r) => r.state)
290-
.filter((v) => v !== "");
290+
?.map((r) => r.state)
291+
?.filter((v) => v !== "");
291292

292-
if (!availableStateValues.includes(row.state))
293-
availableStateValues.push(row.state);
293+
if (!availableStateValues?.includes(row.state))
294+
availableStateValues?.push(row.state);
294295

295-
const areTransitionValuesInvalid = nulPossibleTransitionValues.some(
296+
const areTransitionValuesInvalid = nulPossibleTransitionValues?.some(
296297
(key) => {
297298
const transitionValues = row[key]
298-
.toString()
299-
.split(" ")
300-
.filter((v) => v !== "");
301-
return transitionValues.some(
302-
(v) => !availableStateValues.includes(v)
299+
?.toString()
300+
?.split(" ")
301+
?.filter((v) => v !== "");
302+
return transitionValues?.some(
303+
(v) => !availableStateValues?.includes(v)
303304
);
304305
}
305306
);
@@ -339,11 +340,11 @@ export const Editor = () => {
339340
PossibleTransitionValues.map((key) => [
340341
key === "^" ? "nul" : key,
341342
row[key === "^" ? "nul" : key]
342-
.toString()
343-
.includes(oldRow.state)
343+
?.toString()
344+
?.includes(oldRow.state)
344345
? row[key === "^" ? "nul" : key]
345-
.toString()
346-
.replace(oldRow.state, row.state)
346+
?.toString()
347+
?.replace(oldRow.state, row.state)
347348
: row[key === "^" ? "nul" : key],
348349
])
349350
),
@@ -353,10 +354,10 @@ export const Editor = () => {
353354
...Object.fromEntries(
354355
PossibleTransitionValues.map((key) => [
355356
key === "^" ? "nul" : key,
356-
r[key === "^" ? "nul" : key].toString().includes(oldRow.state)
357+
r[key === "^" ? "nul" : key]?.toString()?.includes(oldRow.state)
357358
? r[key === "^" ? "nul" : key]
358-
.toString()
359-
.replace(oldRow.state, row.state)
359+
?.toString()
360+
?.replace(oldRow.state, row.state)
360361
: r[key === "^" ? "nul" : key],
361362
])
362363
),

0 commit comments

Comments
 (0)