diff --git a/packages/applet-view/src/avoutputarea.ts b/packages/applet-view/src/avoutputarea.ts index 94524ad..9ab19e6 100644 --- a/packages/applet-view/src/avoutputarea.ts +++ b/packages/applet-view/src/avoutputarea.ts @@ -409,9 +409,9 @@ export class AppletViewOutputArea extends AccordionPanel { // clear applets this._applets = []; if (this.layout) { - (this.layout as PanelLayout).widgets.forEach((widget: Widget) => - this.layout?.removeWidget(widget) - ); + // we need a copy, as forEach does not work, if an item is removed + const widgetCopy = [...(this.layout as PanelLayout).widgets]; + widgetCopy.forEach((widget: Widget) => this.layout?.removeWidget(widget)); } if (applets.length === 0) {