Skip to content

Commit 8a156bb

Browse files
fix: added defensive node removal in creation and grading mode
1 parent 2846483 commit 8a156bb

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/components/notebook/create-assignment/creation-switch.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ export class CreationModeSwitch extends React.Component<IModeSwitchProps> {
8686
} else {
8787
currentLayout.widgets.map(w => {
8888
if (w instanceof CreationWidget || w instanceof ErrorWidget) {
89-
currentLayout.removeWidget(w);
89+
try {
90+
currentLayout.removeWidget(w);
91+
} catch(error: any) {
92+
console.log("Could not remove widget: " + w)
93+
console.log("Error: " + error)
94+
}
95+
9096
}
9197
});
9298
}

src/components/notebook/manual-grading/grading-switch.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ export class GradingModeSwitch extends React.Component<IModeSwitchProps> {
160160
} else {
161161
currentLayout.widgets.map(w => {
162162
if (w instanceof DataWidget || w instanceof GradeWidget) {
163-
currentLayout.removeWidget(w);
163+
try {
164+
currentLayout.removeWidget(w);
165+
} catch(error: any) {
166+
console.log("Could not remove widget:" + w)
167+
console.log("Error: " + error)
168+
}
164169
}
165170
});
166171
}

0 commit comments

Comments
 (0)