aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/TabDocView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-06-03 16:02:24 -0400
committerbobzel <zzzman@gmail.com>2022-06-03 16:02:24 -0400
commitba7824a91da113cc813c58b678719092c96d79a2 (patch)
tree4b79859da0933b6634afcc66ade3de199e70d33d /src/client/views/collections/TabDocView.tsx
parent31b2606fa6ac49b0a78e46fcedff05fd2e2366b7 (diff)
fixed opening closed tabs from Files sidebar to re-use best Alias before making a new alias.
Diffstat (limited to 'src/client/views/collections/TabDocView.tsx')
-rw-r--r--src/client/views/collections/TabDocView.tsx15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx
index 8d84e9a56..d64cb2fd7 100644
--- a/src/client/views/collections/TabDocView.tsx
+++ b/src/client/views/collections/TabDocView.tsx
@@ -66,6 +66,8 @@ export class TabDocView extends React.Component<TabDocViewProps> {
get stack() { return (this.props as any).glContainer.parent.parent; }
get tab() { return (this.props as any).glContainer.tab; }
get view() { return this._view; }
+ _lastTab: any;
+ _lastView: DocumentView | undefined;
@action
init = (tab: any, doc: Opt<Doc>) => {
@@ -266,6 +268,7 @@ export class TabDocView extends React.Component<TabDocViewProps> {
componentWillUnmount() {
this._tabReaction?.();
+ this._view && DocumentManager.Instance.RemoveView(this._view);
this.tab && CollectionDockingView.Instance.tabMap.delete(this.tab);
this.props.glContainer.layoutManager.off("activeContentItemChanged", this.onActiveContentItemChanged);
@@ -353,7 +356,11 @@ export class TabDocView extends React.Component<TabDocViewProps> {
@computed get docView() {
return !this._activated || !this._document || this._document._viewType === CollectionViewType.Docking ? (null) :
- <><DocumentView key={this._document[Id]} ref={action((r: DocumentView) => this._view = r)}
+ <><DocumentView key={this._document[Id]} ref={action((r: DocumentView) => {
+ this._lastView && DocumentManager.Instance.RemoveView(this._lastView);
+ this._view = r;
+ this._lastView = this._view;
+ })}
renderDepth={0}
Document={this._document}
DataDoc={!Doc.AreProtosEqual(this._document[DataSym], this._document) ? this._document[DataSym] : undefined}
@@ -409,6 +416,12 @@ export class TabDocView extends React.Component<TabDocViewProps> {
height: "100%", width: "100%"
}} ref={ref => {
if (this._mainCont = ref) {
+ if (this._lastTab) {
+ console.log("DUP tab")
+ this._view && DocumentManager.Instance.RemoveView(this._view);
+ CollectionDockingView.Instance.tabMap.delete(this._lastTab);
+ }
+ this._lastTab = this.tab;
(this._mainCont as any).InitTab = (tab: any) => this.init(tab, this._document);
DocServer.GetRefField(this.props.documentId).then(action(doc => doc instanceof Doc && (this._document = doc) && this.tab && this.init(this.tab, this._document)));
new _global.ResizeObserver(action((entries: any) => this._forceInvalidateScreenToLocal++)).observe(ref);