diff options
author | bobzel <zzzman@gmail.com> | 2024-05-10 11:58:36 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-05-10 11:58:36 -0400 |
commit | e12f79e188c32787b5749eba54183002f270f998 (patch) | |
tree | dcd98c94fd1df9304ca7014642f3b9fe298e99fe | |
parent | d40efe81ab30485266b7b686dfb35c531e75a568 (diff) |
fixed clicking on template text when template is not selected to get focus right. fixed treeView preDrop to compute sameTree correctly so that presbox treeview can nest documents hierarchically properly.
-rw-r--r-- | src/client/views/collections/CollectionSubView.tsx | 4 | ||||
-rw-r--r-- | src/client/views/collections/CollectionTreeView.tsx | 3 | ||||
-rw-r--r-- | src/client/views/nodes/DocumentView.tsx | 24 |
3 files changed, 14 insertions, 17 deletions
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx index a4708bed5..e250d7a90 100644 --- a/src/client/views/collections/CollectionSubView.tsx +++ b/src/client/views/collections/CollectionSubView.tsx @@ -4,7 +4,7 @@ import * as rp from 'request-promise'; import { ClientUtils, returnFalse } from '../../../ClientUtils'; import CursorField from '../../../fields/CursorField'; import { Doc, DocListCast, GetDocFromUrl, GetHrefFromHTML, Opt, RTFIsFragment, StrListCast } from '../../../fields/Doc'; -import { AclPrivate } from '../../../fields/DocSymbols'; +import { AclPrivate, DocData } from '../../../fields/DocSymbols'; import { Id } from '../../../fields/FieldSymbols'; import { List } from '../../../fields/List'; import { listSpec } from '../../../fields/Schema'; @@ -93,7 +93,7 @@ export function CollectionSubView<X>() { } get dataDoc() { - return this._props.TemplateDataDocument instanceof Doc && this.Document.isTemplateForField ? Doc.GetProto(this._props.TemplateDataDocument) : this.Document.resolvedDataDoc ? this.Document : Doc.GetProto(this.Document); // if the layout document has a resolvedDataDoc, then we don't want to get its parent which would be the unexpanded template + return this._props.TemplateDataDocument instanceof Doc && this.Document.isTemplateForField ? Doc.GetProto(this._props.TemplateDataDocument) : this.Document.resolvedDataDoc ? this.Document : this.Document[DocData]; // if the layout document has a resolvedDataDoc, then we don't want to get its parent which would be the unexpanded template } get childContainerViewPath() { diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx index beb8c0666..c39df2c76 100644 --- a/src/client/views/collections/CollectionTreeView.tsx +++ b/src/client/views/collections/CollectionTreeView.tsx @@ -64,9 +64,6 @@ export class CollectionTreeView extends CollectionSubView<Partial<collectionTree makeObservable(this); } - get dataDoc() { - return this._props.TemplateDataDocument || this.Document; - } @computed get treeViewtruncateTitleWidth() { return NumCast(this.Document.treeView_TruncateTitleWidth, this.panelWidth()); } diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index ada3de355..3e154aead 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -343,16 +343,18 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document }, 'click ' + this.Document.title); } else { // onDragStart implies a button doc that we don't want to select when clicking. RootDocument & isTemplateForField implies we're clicking on part of a template instance and we want to select the whole template, not the part - if ((this.layoutDoc.onDragStart || this._props.TemplateDataDocument) && !(e.ctrlKey || e.button > 0)) { - stopPropagate = false; // don't stop propagation for field templates -- want the selection to propagate up to the root document of the template + if (this.layoutDoc.onDragStart && !(e.ctrlKey || e.button > 0)) { + stopPropagate = false; } preventDefault = false; } - const sendToBack = e.altKey; - this._singleClickFunc = - // prettier-ignore - clickFunc ?? (() => (sendToBack ? documentView._props.bringToFront?.(this.Document, true) : - this._props.select(e.ctrlKey||e.shiftKey, e.metaKey))); + const sendToBack = e.altKey ? () => documentView._props.bringToFront?.(this.Document, true) : undefined; + const selectFunc = () => { + // selecting a view that is part of a template proxies the selection back to the root of the template + const templateRoot = !(e.ctrlKey || e.button > 0) && this._props.docViewPath?.().reverse().find(dv => !dv._props.TemplateDataDocument); // prettier-ignore + (templateRoot || this._docView)?.select(e.ctrlKey || e.shiftKey, e.metaKey); + }; + this._singleClickFunc = clickFunc ?? sendToBack ?? selectFunc; const waitFordblclick = this._props.waitForDoubleClickToClick?.() ?? this.Document.waitForDoubleClickToClick; if ((clickFunc && waitFordblclick !== 'never') || waitFordblclick === 'always') { this._doubleClickTimeout && clearTimeout(this._doubleClickTimeout); @@ -377,17 +379,15 @@ export class DocumentViewInternal extends DocComponent<FieldViewProps & Document this._downX = e.clientX; this._downY = e.clientY; this._downTime = Date.now(); - if ((Doc.ActiveTool === InkTool.None || this._props.addDocTab === returnFalse) && !(this._props.TemplateDataDocument && !(e.ctrlKey || e.button > 0))) { - // click events stop here if the document is active and no modes are overriding it - // if this is part of a template, let the event go up to the template root unless right/ctrl clicking + // click events stop here if the document is active and no modes are overriding it + if (Doc.ActiveTool === InkTool.None || this._props.addDocTab === returnFalse) { if ((this._props.isDocumentActive?.() || this._props.isContentActive?.()) && !SnappingManager.ExploreMode && !this.Document.ignoreClick && e.button === 0 && !Doc.IsInMyOverlay(this.layoutDoc) ) { - e.stopPropagation(); - // don't preventDefault. Goldenlayout, PDF text selection and RTF text selection all need it to go though + e.stopPropagation(); // don't preventDefault. Goldenlayout, PDF text selection and RTF text selection all need it to go though // listen to move events when document content isn't active or document is always draggable if (!this.layoutDoc._lockedPosition && (!this.isContentActive() || BoolCast(this.layoutDoc._dragWhenActive, this._props.dragWhenActive))) { |