aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2020-10-13 11:02:13 -0400
committerbobzel <zzzman@gmail.com>2020-10-13 11:02:13 -0400
commit0d630f812d0924bac0863be62dbd3cdfc2b9e2c1 (patch)
tree749725b6252baa35d91531a513c6047e2d82a548 /src
parent8ebf3cb0ac7a023aa47a5264d74c3edaebf28b1b (diff)
fixed expand template layout to create delegate in timeout -- otherwise it can violate mobx computed values which may trigger it.
Diffstat (limited to 'src')
-rw-r--r--src/fields/Doc.ts15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index cea09b9c5..c8d28b4a2 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -679,16 +679,15 @@ export namespace Doc {
} else {
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
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(() => {
+ 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;
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 });
}