From a7d5b7da561715c8f78cac94efe37cd4b6266188 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 23 Oct 2020 13:16:15 -0400
Subject: fixed major performance/bug with replaceTab AddDocTab where they
 weren't in an action so lots of extra/wrong work was being done.  Now
 switching slides should work when they open new tabs.

---
 src/client/views/collections/CollectionDockingView.tsx | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'src/client/views/collections/CollectionDockingView.tsx')

diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 39a52fb6d..d2c065417 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -108,6 +108,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
     }
 
     @undoBatch
+    @action
     public static ReplaceTab(document: Doc, panelName: string, stack: any, addToSplit?: boolean): boolean {
         const instance = CollectionDockingView.Instance;
         if (!instance) return false;
@@ -140,8 +141,15 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
     //  Creates a split on any side of the docking view based on the passed input pullSide and then adds the Document to the requested side
     //
     @undoBatch
+    @action
     public static AddSplit(document: Doc, pullSide: string, stack?: any, panelName?: string) {
         if (document._viewType === CollectionViewType.Docking) return CurrentUserUtils.openDashboard(Doc.UserDoc(), document);
+
+        const tab = Array.from(CollectionDockingView.Instance.tabMap).find(tab => tab.DashDoc === document);
+        if (tab) {
+            tab.header.parent.setActiveContentItem(tab.contentItem);
+            return true;
+        }
         const instance = CollectionDockingView.Instance;
         if (!instance) return false;
         const docContentConfig = CollectionDockingView.makeDocumentConfig(document, panelName);
-- 
cgit v1.2.3-70-g09d2

