diff --git a/app/renderer/js/main.js b/app/renderer/js/main.js index 9251745c3..69374f7ba 100644 --- a/app/renderer/js/main.js +++ b/app/renderer/js/main.js @@ -159,22 +159,24 @@ class ServerManagerView { const showSidebar = ConfigUtil.getConfigItem('showSidebar', true); this.toggleSidebar(showSidebar); // Allow dragging of server tabs and update the data-tab-id - const onEnd = event => { + const onEnd = () => { const newTabs = []; const domains = []; + const indexMap = {}; const tabElements = document.querySelectorAll('#tabs-container .tab'); tabElements.forEach((el, index) => { const oldIndex = +Number(el.getAttribute('data-tab-id')) % tabElements.length; el.setAttribute('data-tab-id', index.toString()); domains.push(DomainUtil.getDomain(oldIndex)); newTabs.push(this.tabs[oldIndex]); + indexMap[String(oldIndex)] = index; this.replaceServer(domains[index], index, oldIndex); }); for (let index = 0; index < domains.length; ++index) { DomainUtil.updateSavedServer(domains[index].url, index); } + this.activeTabIndex = indexMap[String(this.activeTabIndex)]; this.tabs = newTabs; - this.activeTabIndex = event.newIndex; ipcRenderer.send('update-menu', { tabs: this.tabs, activeTabIndex: this.activeTabIndex @@ -238,6 +240,10 @@ class ServerManagerView { const onHoverOut = this.onHoverOut.bind(this, oldIndex); this.tabs[index].updateListeners(onClick, onHover, onHoverOut); this.tabs[index].updateShortcutText(index); + this.tabs[index].webview.props.index = index; + this.tabs[index].webview.props.isActive = () => { + return oldIndex === this.activeTabIndex; + }; } initActions() {