From 9f048fee0c44264f8eac8326b9e0945d1426c1f5 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sat, 22 Aug 2020 00:15:04 -0400 Subject: selecting a tab doc in a tree view makes the tab active in the Dashboard. fixed stacking view's maxHeight to be _maxHeight --- src/client/views/collections/CollectionDockingView.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (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 faa9d4901..83321d6e0 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -438,9 +438,8 @@ export class CollectionDockingView extends React.Component { const cur = this._containerRef.current; - // bcz: since GoldenLayout isn't a React component itself, we need to notify it to resize when its document container's size has changed - this._goldenLayout?.updateSize(cur!.getBoundingClientRect().width, cur!.getBoundingClientRect().height); + cur && this._goldenLayout?.updateSize(cur.getBoundingClientRect().width, cur.getBoundingClientRect().height); } @action @@ -583,6 +582,12 @@ export class CollectionDockingView extends React.Component SelectionManager.SelectedDocuments(), + (sel) => { + const selected = sel.some(v => v.props.Document === doc); + selected && tab.contentItem !== tab.header.parent.getActiveContentItem() && tab.header.parent.setActiveContentItem(tab.contentItem); + } + ); tab.buttonDisposer = reaction(() => ((view: Opt) => view ? [view] : [])(DocumentManager.Instance.getDocumentView(doc)), (views) => { if (views.length) { @@ -607,6 +612,7 @@ export class CollectionDockingView extends React.Component { })); observer.observe(this.props.glContainer._element[0]); this.props.glContainer.layoutManager.on("activeContentItemChanged", this.onActiveContentItemChanged); - this.props.glContainer.on("tab", this.onActiveContentItemChanged); - this.onActiveContentItemChanged(); + this.props.glContainer.tab?.isActive && this.onActiveContentItemChanged(); this._tabReaction = reaction(() => ({ views: SelectionManager.SelectedDocuments(), color: StrCast(this._document?._backgroundColor, this._document && CollectionDockingView.Instance?.props.backgroundColor?.(this._document, 0) || "white") }), (data) => { const selected = data.views.some(v => Doc.AreProtosEqual(v.props.Document, this._document)); @@ -795,14 +800,13 @@ export class DockedFrameRenderer extends React.Component { componentWillUnmount() { this._tabReaction?.(); this.props.glContainer.layoutManager.off("activeContentItemChanged", this.onActiveContentItemChanged); - this.props.glContainer.off("tab", this.onActiveContentItemChanged); } @action.bound private onActiveContentItemChanged() { - if (this.props.glContainer.tab) { + if (this.props.glContainer.tab && this._isActive !== this.props.glContainer.tab.isActive) { this._isActive = this.props.glContainer.tab.isActive; - setTimeout(() => { + this._isActive && setTimeout(() => { const dv = this._document && DocumentManager.Instance.getFirstDocumentView(this._document); dv && SelectionManager.SelectDoc(dv, false); }); -- cgit v1.2.3-70-g09d2