diff --git a/frontend/src/components/SimpleTests/SimpleTests.tsx b/frontend/src/components/SimpleTests/SimpleTests.tsx index dd76da91..d79256f6 100644 --- a/frontend/src/components/SimpleTests/SimpleTests.tsx +++ b/frontend/src/components/SimpleTests/SimpleTests.tsx @@ -365,7 +365,18 @@ export default function SimpleTests(props: { // check local const oldConstraint = local_constraints_plus_zip.find(constraint => constraint.id === id); const newConstraint = new Constraint(type, "CHANGE_ME", newId, id, oldConstraint!.depth+1); - const sub_items = zip.local_constraints.filter(constraint => constraint.parent_id === id); + + const sub_item_ids = [id]; // get subitems recursively + const sub_items: Constraint[] = []; + for (const try_sub_constraint of zip.local_constraints) { + if (try_sub_constraint.parent_id !== undefined) { + if (sub_item_ids.includes(try_sub_constraint.parent_id)) { + sub_item_ids.push(try_sub_constraint.id); + sub_items.push(try_sub_constraint); + } + } + } + let index!: number; if (sub_items.length === 0) { // No sub-items yet. Put directly after item. @@ -640,9 +651,9 @@ export default function SimpleTests(props: { contentStyle={{width: 'auto'}} >
- - - + + +
}