diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2019-08-28 21:40:12 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2019-08-28 21:40:12 -0400 |
commit | 24f87285011b4cff8518a12442410a99f0a97cb8 (patch) | |
tree | 20492ee77e77d4bf1440a2560d64b6b06e982c24 | |
parent | 4b7672c75fe5cdf6afe534e67213917b24980c3e (diff) |
fixed template bug related to childLayouts
-rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 62f848a2b..a7acd9e91 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -182,18 +182,29 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) { private get _pheight() { return this.props.PanelHeight(); } private inkKey = "ink"; private _childLayoutDisposer?: IReactionDisposer; + private _childDisposer?: IReactionDisposer; componentDidMount() { - this._childLayoutDisposer = reaction(() => [this.childDocs, Cast(this.props.Document.childLayout, Doc)], - async (args) => { - this.childDocs.filter(doc => args[1] instanceof Doc || doc.layout instanceof Doc).map(async doc => { - if (!Doc.AreProtosEqual(args[1] as Doc, (await doc).layout as Doc)) { - Doc.ApplyTemplateTo(args[1] as Doc, (await doc), undefined); + this._childDisposer = reaction(() => this.childDocs, + async (childDocs) => { + let childLayout = Cast(this.props.Document.childLayout, Doc) as Doc; + childLayout && childDocs.map(async doc => { + if (!Doc.AreProtosEqual(childLayout, (await doc).layout as Doc)) { + Doc.ApplyTemplateTo(childLayout, doc, undefined); + } + }); + }); + this._childLayoutDisposer = reaction(() => Cast(this.props.Document.childLayout, Doc), + async (childLayout) => { + this.childDocs.map(async doc => { + if (!Doc.AreProtosEqual(childLayout as Doc, (await doc).layout as Doc)) { + Doc.ApplyTemplateTo(childLayout as Doc, doc, undefined); } }); }); } componentWillUnmount() { + this._childDisposer && this._childDisposer(); this._childLayoutDisposer && this._childLayoutDisposer(); } |