From ab7d121290eecf3ade934c39861b3cfea188b73d Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 28 Oct 2021 22:27:21 +0200 Subject: [PATCH] disallow removing last tab because of frequent race conditions when done too quickly --- src/public/app/services/tab_manager.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/public/app/services/tab_manager.js b/src/public/app/services/tab_manager.js index 45971e331..d14107ad2 100644 --- a/src/public/app/services/tab_manager.js +++ b/src/public/app/services/tab_manager.js @@ -299,6 +299,16 @@ export default class TabManager extends Component { async removeNoteContext(ntxId) { const noteContextToRemove = this.getNoteContextById(ntxId); + if (noteContextToRemove.isMainContext()) { + // forbid removing last main note context + // this was previously allowed (was replaced with empty tab) but this proved to be prone to race conditions + const mainNoteContexts = this.getNoteContexts().filter(nc => nc.isMainContext()); + + if (mainNoteContexts.length === 1) { + return; + } + } + // close dangling autocompletes after closing the tab $(".aa-input").autocomplete("close");