diff options
-rw-r--r-- | src/client/util/DocumentManager.ts | 2 | ||||
-rw-r--r-- | src/client/views/collections/TabDocView.scss | 12 | ||||
-rw-r--r-- | src/client/views/collections/TabDocView.tsx | 10 | ||||
-rw-r--r-- | src/fields/Doc.ts | 30 |
4 files changed, 32 insertions, 22 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index 903760c58..c3d78a028 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -162,8 +162,6 @@ export class DocumentManager { docView.props.Document.hidden = !docView.props.Document.hidden; } else { - const contView = docContext && getFirstDocView(docContext, originatingDoc); - contView && contView.topMost && contView.select(false); // bcz: change this to a function prop: popTab() that will make sure the tab for the document is topmost; docView.select(false); docView.props.Document.hidden && (docView.props.Document.hidden = undefined); docView.props.focus(docView.props.Document, willZoom, undefined, focusAndFinish); diff --git a/src/client/views/collections/TabDocView.scss b/src/client/views/collections/TabDocView.scss index c0a46543d..5dfb9366a 100644 --- a/src/client/views/collections/TabDocView.scss +++ b/src/client/views/collections/TabDocView.scss @@ -1,5 +1,13 @@ -input.lm_title:focus { - max-width: max-content !important; +input.lm_title:focus, +input.lm_title +{ + max-width: unset !important; + transition-delay: unset; + width: 100%; +} +input.lm_title { + transition-delay: 0.35s; + width: 100px; } .miniMap-hidden, .miniMap { diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx index 62f6d50fc..76ca82c63 100644 --- a/src/client/views/collections/TabDocView.tsx +++ b/src/client/views/collections/TabDocView.tsx @@ -61,7 +61,6 @@ export class TabDocView extends React.Component<TabDocViewProps> { const titleEle = tab.titleElement[0]; titleEle.size = StrCast(doc.title).length + 3; titleEle.value = doc.title; - titleEle.style["max-width"] = "100px"; titleEle.onchange = (e: any) => { titleEle.size = e.currentTarget.value.length + 3; Doc.GetProto(doc).title = e.currentTarget.value; @@ -81,7 +80,7 @@ export class TabDocView extends React.Component<TabDocViewProps> { }; // select the tab document when the tab is directly clicked and activate the tab whenver the tab document is selected - tab.element[0].onclick = (e: any) => { + titleEle.onpointerdown = (e: any) => { if (e.target.className !== "lm_close_tab" && this.view) { SelectionManager.SelectDoc(this.view, false); if (Date.now() - titleEle.lastClick < 1000) titleEle.select(); @@ -197,7 +196,7 @@ export class TabDocView extends React.Component<TabDocViewProps> { this._isActive = this.props.glContainer.tab.isActive; (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); + // this._isActive && this.view && SelectionManager.SelectDoc(this.view, false); } } @@ -339,7 +338,10 @@ export class TabDocView extends React.Component<TabDocViewProps> { </Tooltip> </>; } - focusFunc = (doc: Doc, willZoom: boolean, scale?: number, afterFocus?: () => void) => afterFocus?.(); + focusFunc = (doc: Doc, willZoom: boolean, scale?: number, afterFocus?: () => void) => { + this.tab.header.parent.setActiveContentItem(this.tab.contentItem) + afterFocus?.(); + } setView = action((view: DocumentView) => this._view = view); active = () => this._isActive; @computed get docView() { diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index ff45dda80..a8950f1ee 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -688,24 +688,26 @@ export namespace Doc { if (templateLayoutDoc.resolvedDataDoc === (targetDoc.rootDocument || Doc.GetProto(targetDoc)) && templateLayoutDoc.PARAMS === StrCast(targetDoc.PARAMS)) { expandedTemplateLayout = templateLayoutDoc; // reuse an existing template layout if its for the same document with the same params } else { - _pendingMap.set(targetDoc[Id] + expandedLayoutFieldKey + args, true); templateLayoutDoc.resolvedDataDoc && (templateLayoutDoc = Cast(templateLayoutDoc.proto, Doc, null) || templateLayoutDoc); // if the template has already been applied (ie, a nested template), then use the template's prototype - setTimeout(action(() => { - if (!targetDoc[expandedLayoutFieldKey]) { - const newLayoutDoc = Doc.MakeDelegate(templateLayoutDoc, undefined, "[" + templateLayoutDoc.title + "]"); - // the template's arguments are stored in params which is derefenced to find - // the actual field key where the parameterized template data is stored. - newLayoutDoc[params] = args !== "..." ? args : ""; // ... signifies the layout has sub template(s) -- so we have to expand the layout for them so that they can get the correct 'rootDocument' field, but we don't need to reassign their params. it would be better if the 'rootDocument' field could be passed dynamically to avoid have to create instances - newLayoutDoc.rootDocument = targetDoc; - targetDoc[expandedLayoutFieldKey] = newLayoutDoc; - const dataDoc = Doc.GetProto(targetDoc); - newLayoutDoc.resolvedDataDoc = dataDoc; - if (dataDoc[templateField] === undefined && templateLayoutDoc[templateField] instanceof List) { + if (!targetDoc[expandedLayoutFieldKey]) { + const newLayoutDoc = Doc.MakeDelegate(templateLayoutDoc, undefined, "[" + templateLayoutDoc.title + "]"); + // the template's arguments are stored in params which is derefenced to find + // the actual field key where the parameterized template data is stored. + newLayoutDoc[params] = args !== "..." ? args : ""; // ... signifies the layout has sub template(s) -- so we have to expand the layout for them so that they can get the correct 'rootDocument' field, but we don't need to reassign their params. it would be better if the 'rootDocument' field could be passed dynamically to avoid have to create instances + newLayoutDoc.rootDocument = targetDoc; + const dataDoc = Doc.GetProto(targetDoc); + newLayoutDoc.resolvedDataDoc = dataDoc; + + _pendingMap.set(targetDoc[Id] + expandedLayoutFieldKey + args, true); + setTimeout(() => { + if (dataDoc[templateField] === undefined && templateLayoutDoc[templateField] instanceof List && (templateLayoutDoc[templateField] as any).length) { dataDoc[templateField] = ComputedField.MakeFunction(`ObjectField.MakeCopy(templateLayoutDoc["${templateField}"] as List)`, { templateLayoutDoc: Doc.name }, { templateLayoutDoc }); } + targetDoc[expandedLayoutFieldKey] = newLayoutDoc; + _pendingMap.delete(targetDoc[Id] + expandedLayoutFieldKey + args); - } - }), 0); + }); + } } } return expandedTemplateLayout instanceof Doc ? expandedTemplateLayout : undefined; // layout is undefined if the expandedTemplateLayout is pending. |