From 329c2f943e5a7930381d67157a82cba719aa33e5 Mon Sep 17 00:00:00 2001 From: IRBorisov <8611739+IRBorisov@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:50:07 +0300 Subject: [PATCH] Fix bug on deleting last cst --- .../frontend/src/pages/RSFormPage/EditorConstituenta.tsx | 2 -- rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta.tsx index cea063aa..f832ec7b 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta.tsx @@ -72,8 +72,6 @@ function EditorConstituenta({ activeID, onShowAST, onCreateCst, onRenameCst, onO setTextDefinition(activeCst.definition?.text?.raw ?? ''); setExpression(activeCst.definition?.formal ?? ''); setTypification(activeCst ? getCstTypificationLabel(activeCst) : 'N/A'); - } else if (schema && schema?.items.length > 0) { - onOpenEdit(schema.items[0].id); } }, [activeCst, onOpenEdit, schema]); diff --git a/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx b/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx index ac2bb7b6..d25b1db3 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx @@ -163,6 +163,12 @@ function RSTabs() { while (activeIndex < schema.items.length && deleted.find(id => id === schema.items[activeIndex].id)) { ++activeIndex; } + if (activeIndex >= schema.items.length) { + activeIndex = schema.items.length - 1; + while (activeIndex >= 0 && deleted.find(id => id === schema.items[activeIndex].id)) { + --activeIndex; + } + } navigateTo(activeTab, schema.items[activeIndex].id); } if (afterDelete) afterDelete(deleted);