aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/TabDocView.tsx
diff options
context:
space:
mode:
authorLionel Han <47760119+IGoByJoe@users.noreply.github.com>2020-09-09 22:18:39 -0700
committerLionel Han <47760119+IGoByJoe@users.noreply.github.com>2020-09-09 22:18:39 -0700
commit1b8eb5a59edfcef36e8f6450aca82de46d2044eb (patch)
treee9f4aaaa27c71ca51fca9ee18af00d88b827574c /src/client/views/collections/TabDocView.tsx
parente641fd8c6f5a84800af173db02bd012eecb04b7a (diff)
parent5a4dad460f611cb8138faf08796dda4763f4daf4 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into bug_fixes
Diffstat (limited to 'src/client/views/collections/TabDocView.tsx')
-rw-r--r--src/client/views/collections/TabDocView.tsx18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx
index fb4f5c366..589649ad9 100644
--- a/src/client/views/collections/TabDocView.tsx
+++ b/src/client/views/collections/TabDocView.tsx
@@ -68,7 +68,6 @@ export class TabDocView extends React.Component<TabDocViewProps> {
tab.element[0].onmouseenter = (e: MouseEvent) => {
if (SnappingManager.GetIsDragging() && tab.contentItem !== tab.header.parent.getActiveContentItem()) {
tab.header.parent.setActiveContentItem(tab.contentItem);
- console.log("Seetting " + titleEle.value);
tab.setActive(true);
}
};
@@ -88,7 +87,7 @@ export class TabDocView extends React.Component<TabDocViewProps> {
(document.activeElement !== titleEle) && titleEle.focus();
}
};
- tab._disposers.selectionDisposer = reaction(() => SelectionManager.SelectedDocuments().some(v => v.topMost && v.props.Document === doc),
+ tab._disposers.selectionDisposer = reaction(() => SelectionManager.SelectedDocuments().some(v => (v.topMost || v.props.treeViewDoc) && v.props.Document === doc),
(selected) => selected && tab.contentItem !== tab.header.parent.getActiveContentItem() &&
UndoManager.RunInBatch(() => tab.header.parent.setActiveContentItem(tab.contentItem), "tab switch"));
@@ -190,9 +189,9 @@ export class TabDocView extends React.Component<TabDocViewProps> {
private onActiveContentItemChanged() {
if (this.props.glContainer.tab && this._isActive !== this.props.glContainer.tab.isActive) {
this._isActive = this.props.glContainer.tab.isActive;
- this._isActive && setTimeout(() => this.view && SelectionManager.SelectDoc(this.view, false), 0);
(CollectionDockingView.Instance as any)._goldenLayout?.isInitialised && CollectionDockingView.Instance.stateChanged();
!this._isActive && this._document && Doc.UnBrushDoc(this._document); // bcz: bad -- trying to simulate a pointer leave event when a new tab is opened up on top of an existing one.
+ this._isActive && this.view && SelectionManager.SelectDoc(this.view, false);
}
}
@@ -228,8 +227,8 @@ export class TabDocView extends React.Component<TabDocViewProps> {
}
return Transform.Identity();
}
- get previewPanelCenteringOffset() { return this.nativeWidth() ? (this._panelWidth - this.nativeWidth() * this.contentScaling()) / 2 : 0; }
- get widthpercent() { return this.nativeWidth() ? `${(this.nativeWidth() * this.contentScaling()) / this._panelWidth * 100}% ` : undefined; }
+ @computed get previewPanelCenteringOffset() { return this.nativeWidth() ? (this._panelWidth - this.nativeWidth() * this.contentScaling()) / 2 : 0; }
+ @computed get widthpercent() { return this.nativeWidth() ? `${(this.nativeWidth() * this.contentScaling()) / this._panelWidth * 100}% ` : undefined; }
// adds a tab to the layout based on the locaiton parameter which can be:
// close[:{left,right,top,bottom}] - e.g., "close" will close the tab, "close:left" will close the left tab,
@@ -306,8 +305,6 @@ export class TabDocView extends React.Component<TabDocViewProps> {
ContentScaling={returnOne}
PanelWidth={this.returnMiniSize}
PanelHeight={this.returnMiniSize}
- NativeHeight={returnZero}
- NativeWidth={returnZero}
ScreenToLocalTransform={this.ScreenToLocalTransform}
renderDepth={0}
whenActiveChanged={emptyFunction}
@@ -332,6 +329,7 @@ export class TabDocView extends React.Component<TabDocViewProps> {
}
focusFunc = (doc: Doc, willZoom: boolean, scale?: number, afterFocus?: () => void) => afterFocus?.();
setView = action((view: DocumentView) => this._view = view);
+ active = () => this._isActive;
@computed get docView() {
TraceMobx();
return !this._document || this._document._viewType === CollectionViewType.Docking ? (null) :
@@ -347,11 +345,11 @@ export class TabDocView extends React.Component<TabDocViewProps> {
ContentScaling={this.contentScaling}
PanelWidth={this.panelWidth}
PanelHeight={this.panelHeight}
- NativeHeight={this.nativeHeight}
- NativeWidth={this.nativeWidth}
+ NativeHeight={this.nativeHeight() ? this.nativeHeight : undefined}
+ NativeWidth={this.nativeWidth() ? this.nativeWidth : undefined}
ScreenToLocalTransform={this.ScreenToLocalTransform}
renderDepth={0}
- parentActive={returnTrue}
+ parentActive={this.active}
whenActiveChanged={emptyFunction}
focus={this.focusFunc}
backgroundColor={CollectionDockingView.Instance.props.backgroundColor}