Skip to content

Commit

Permalink
fix: 🐛 Don't allow blank hierarchy fields
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 22, 2021
1 parent e4eebc6 commit 2a17ef9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/Components/UserHierarchies.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@
name={dir}
value={hier[dir]?.join(", ") ?? ""}
on:change={async (e) => {
currHiers[i][dir] = splitAndTrim(e.target.value);
const { value } = e.target;
if (value === "") {
currHiers[i][dir] = [];
} else {
currHiers[i][dir] = splitAndTrim(value);
}
await update(currHiers);
}}
/>
Expand Down
7 changes: 4 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ export default class BCPlugin extends Plugin {
const { limitTrailCheckboxStates, userHiers } = this.settings;
const upFields = getFields(userHiers, "up");
const downFields = getFields(userHiers, "down");

let subGraph: MultiGraph;

if (Object.values(limitTrailCheckboxStates).every((val) => val)) {
Expand All @@ -978,9 +979,9 @@ export default class BCPlugin extends Plugin {
const positiveFields = Object.keys(limitTrailCheckboxStates).filter(
(field) => limitTrailCheckboxStates[field]
);
const oppFields = positiveFields.map(
(field) => getOppFields(userHiers, field)[0]
);
const oppFields = positiveFields
.map((field) => getOppFields(userHiers, field)[0])
.filter((field) => field !== undefined);
subGraph = getSubForFields(this.mainG, [...positiveFields, ...oppFields]);
}

Expand Down
1 change: 1 addition & 0 deletions src/sharedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export function getReflexiveClosure(
const copy = g.copy();
copy.forEachEdge((k, a, s, t) => {
const { dir, field } = a;
if (field === undefined) return;
const oppDir = getOppDir(dir);
const oppField = getOppFields(userHiers, field)[0];

Expand Down

0 comments on commit 2a17ef9

Please sign in to comment.