From 7caca95c05a1c8164eadd42f9854988c141283f5 Mon Sep 17 00:00:00 2001
From: Maximilian Giller <m.giller@tu-bs.de>
Date: Wed, 28 Sep 2022 16:11:06 +0200
Subject: [PATCH] Improved handling of deleting last space

---
 src/editor/editor.tsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/editor/editor.tsx b/src/editor/editor.tsx
index 5b5a803..ef9a3e8 100644
--- a/src/editor/editor.tsx
+++ b/src/editor/editor.tsx
@@ -462,9 +462,12 @@ export class Editor extends React.PureComponent<any, stateTypes> {
     private deleteSpace(spaceId: string): Promise<void> {
         return deleteGraphJson(spaceId).then(() => {
             // Select first space in list if available, otherwise select defaul space (which will be created)
+            const remainingSpacesList: string[] = this.state.spaces.filter(
+                (space: string) => space != spaceId
+            );
             const selectSpaceId: string =
-                this.state.spaces.length > 0
-                    ? this.state.spaces[0]
+                remainingSpacesList.length > 0
+                    ? remainingSpacesList[0]
                     : Config.SPACE;
 
             this.loadSpace(selectSpaceId);
-- 
GitLab