fix orphan note autocomplete, closes #569

This commit is contained in:
zadam 2019-06-24 20:45:35 +02:00
parent 3f241553aa
commit 1b831f94a9
2 changed files with 11 additions and 8 deletions

File diff suppressed because one or more lines are too long

View file

@ -401,11 +401,14 @@ tabRow.addListener('activeTabChange', async ({ detail }) => {
tabRow.addListener('tabRemove', async ({ detail }) => {
const tabId = detail.tabEl.getAttribute('data-tab-id');
const tabContentToDelete = tabContexts.find(nc => nc.tabId === tabId);
const tabContextToDelete = tabContexts.find(nc => nc.tabId === tabId);
if (tabContentToDelete) {
await tabContentToDelete.saveNoteIfChanged();
tabContentToDelete.$tabContent.remove();
if (tabContextToDelete) {
// sometimes there are orphan autocompletes after closing the tab
tabContextToDelete.$tabContent.find('.aa-input').autocomplete('close');
await tabContextToDelete.saveNoteIfChanged();
tabContextToDelete.$tabContent.remove();
}
tabContexts = tabContexts.filter(nc => nc.tabId !== tabId);