aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-02-10 11:41:26 -0500
committerbobzel <zzzman@gmail.com>2021-02-10 11:41:26 -0500
commit5e9faf9fc5a2aeb3b5c0377b756a746934097619 (patch)
tree3a1f23e2289827fe0214f92666f3635db5fd9da9 /src/client/views/nodes
parent861363c59997db5cde1b96786b156b64630465d7 (diff)
changed docViewPath to be a function to avoid mobx invalidations
Diffstat (limited to 'src/client/views/nodes')
-rw-r--r--src/client/views/nodes/DocumentView.tsx9
-rw-r--r--src/client/views/nodes/KeyValuePair.tsx2
-rw-r--r--src/client/views/nodes/LinkDocPreview.tsx2
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx2
4 files changed, 8 insertions, 7 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 8afa53eac..190dfd6be 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -65,7 +65,7 @@ export interface DocumentViewSharedProps {
CollectionFreeFormDocumentView?: () => CollectionFreeFormDocumentView;
PanelWidth: () => number;
PanelHeight: () => number;
- docViewPath: DocumentView[];
+ docViewPath: () => DocumentView[];
layerProvider: undefined | ((doc: Doc, assign?: boolean) => boolean);
styleProvider: Opt<StyleProviderFunc>;
focus: DocFocusFunc;
@@ -117,7 +117,7 @@ export interface DocumentViewInternalProps extends DocumentViewProps {
isSelected: (outsideReaction?: boolean) => boolean;
select: (ctrlPressed: boolean) => void;
DocumentView: any;
- viewPath: DocumentView[];
+ viewPath: () => DocumentView[];
}
@observer
@@ -884,7 +884,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
get allLinks() { return this.docView?.allLinks || []; }
get LayoutFieldKey() { return this.docView?.LayoutFieldKey || "layout"; }
- @computed get docViewPath() { return this.props.docViewPath ? [...this.props.docViewPath, this] : [this]; }
+ @computed get docViewPath() { return this.props.docViewPath ? [...this.props.docViewPath(), this] : [this]; }
@computed get layoutDoc() { return Doc.Layout(this.Document, this.props.LayoutTemplate?.()); }
@computed get nativeWidth() { return returnVal(this.props.NativeWidth?.(), Doc.NativeWidth(this.layoutDoc, this.props.DataDoc, this.props.freezeDimensions)); }
@computed get nativeHeight() { return returnVal(this.props.NativeHeight?.(), Doc.NativeHeight(this.layoutDoc, this.props.DataDoc, this.props.freezeDimensions) || 0); }
@@ -955,6 +955,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
}), 400);
});
+ docViewPathFunc = () => this.docViewPath;
isSelected = (outsideReaction?: boolean) => SelectionManager.IsSelected(this, outsideReaction);
select = (ctrlPressed: boolean) => SelectionManager.SelectView(this, ctrlPressed);
NativeWidth = () => this.nativeWidth;
@@ -978,7 +979,7 @@ export class DocumentView extends React.Component<DocumentViewProps> {
const internalProps = {
...this.props,
DocumentView: this,
- viewPath: this.docViewPath,
+ viewPath: this.docViewPathFunc,
PanelWidth: this.PanelWidth,
PanelHeight: this.PanelHeight,
NativeWidth: this.NativeWidth,
diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx
index 6f222d53b..ce9d8bed5 100644
--- a/src/client/views/nodes/KeyValuePair.tsx
+++ b/src/client/views/nodes/KeyValuePair.tsx
@@ -61,7 +61,7 @@ export class KeyValuePair extends React.Component<KeyValuePairProps> {
searchFilterDocs: returnEmptyDoclist,
styleProvider: DefaultStyleProvider,
layerProvider: undefined,
- docViewPath: emptyPath,
+ docViewPath: returnEmptyDoclist,
ContainingCollectionView: undefined,
ContainingCollectionDoc: undefined,
fieldKey: this.props.keyName,
diff --git a/src/client/views/nodes/LinkDocPreview.tsx b/src/client/views/nodes/LinkDocPreview.tsx
index eb27a6241..6155ed493 100644
--- a/src/client/views/nodes/LinkDocPreview.tsx
+++ b/src/client/views/nodes/LinkDocPreview.tsx
@@ -145,7 +145,7 @@ export class LinkDocPreview extends React.Component<LinkDocPreviewProps> {
rootSelected={returnFalse}
styleProvider={this.props.docProps?.styleProvider}
layerProvider={this.props.docProps?.layerProvider}
- docViewPath={emptyPath}
+ docViewPath={returnEmptyDoclist}
ScreenToLocalTransform={Transform.Identity}
parentActive={returnFalse}
addDocument={returnFalse}
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index a91157519..9e2e8f1be 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -1245,7 +1245,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
(this._editorView as any).TextView = this;
}
- const selectOnLoad = this.rootDoc[Id] === FormattedTextBox.SelectOnLoad && (!LightboxView.LightboxDoc || this.props.docViewPath.includes(LightboxView.LightboxDocView.current!));
+ const selectOnLoad = this.rootDoc[Id] === FormattedTextBox.SelectOnLoad && (!LightboxView.LightboxDoc || this.props.docViewPath().includes(LightboxView.LightboxDocView.current!));
if (selectOnLoad && !this.props.dontRegisterView && !this.props.dontSelectOnLoad && this.isActiveTab(this.ProseRef)) {
FormattedTextBox.SelectOnLoad = "";
this.props.select(false);