Fix bug on deleting last cst

This commit is contained in:
IRBorisov 2023-08-28 10:50:07 +03:00
parent 91c318f36a
commit 329c2f943e
2 changed files with 6 additions and 2 deletions

View File

@ -72,8 +72,6 @@ function EditorConstituenta({ activeID, onShowAST, onCreateCst, onRenameCst, onO
setTextDefinition(activeCst.definition?.text?.raw ?? ''); setTextDefinition(activeCst.definition?.text?.raw ?? '');
setExpression(activeCst.definition?.formal ?? ''); setExpression(activeCst.definition?.formal ?? '');
setTypification(activeCst ? getCstTypificationLabel(activeCst) : 'N/A'); setTypification(activeCst ? getCstTypificationLabel(activeCst) : 'N/A');
} else if (schema && schema?.items.length > 0) {
onOpenEdit(schema.items[0].id);
} }
}, [activeCst, onOpenEdit, schema]); }, [activeCst, onOpenEdit, schema]);

View File

@ -163,6 +163,12 @@ function RSTabs() {
while (activeIndex < schema.items.length && deleted.find(id => id === schema.items[activeIndex].id)) { while (activeIndex < schema.items.length && deleted.find(id => id === schema.items[activeIndex].id)) {
++activeIndex; ++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); navigateTo(activeTab, schema.items[activeIndex].id);
} }
if (afterDelete) afterDelete(deleted); if (afterDelete) afterDelete(deleted);