From 48ed2689686bebbb284413537bdc545c66254950 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 28 Jun 2018 10:28:35 +0200 Subject: [PATCH] matrix: refine widget recreation process on props update --- src/browser/js/app/widgets/matrices/matrix.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/browser/js/app/widgets/matrices/matrix.js b/src/browser/js/app/widgets/matrices/matrix.js index ea492811..e78e49a9 100644 --- a/src/browser/js/app/widgets/matrices/matrix.js +++ b/src/browser/js/app/widgets/matrices/matrix.js @@ -93,16 +93,30 @@ class Matrix extends _matrix_base { case 'props': + var hashes = [...this.childrenHashes] + this.childrenHashes = [] - for (var i in this.childrenHashes) { + for (var i in hashes) { - let widget = widgetManager.widgets[this.childrenHashes[i]], + let widget = widgetManager.widgets[hashes[i]], data = this.resolveProp('props', undefined, false, false, false, {'i':i}) Object.assign(widget.props, data) widget.updateProps(Object.keys(data), this) } + + if (!this.childrenHashes.length) { + // only dynamic props updated + this.childrenHashes = hashes + } else { + // widgets recreated + for (i in this.childrenHashes) { + let widget = widgetManager.widgets[this.childrenHashes[i]] + widget.container.classList.add('not-editable') + } + } + return }