From ab97f0d55a8db662d74ccee42a739ddb4f064438 Mon Sep 17 00:00:00 2001 From: Bob Gallagher Date: Wed, 19 Apr 2017 15:44:11 -0400 Subject: [PATCH] =?utf8?q?Fix=20problem=20where=20the=20connection-point?= =?utf8?q?=20UI=20was=20not=20updating=20list=20correctly=20when=20button?= =?utf8?q?=20clicked=20to=20deleted=20a=20cp.=20-=20this=20would=20actuall?= =?utf8?q?y=20apply=20to=20any=20=E2=80=9Clist=E2=80=9D=20-=20issue=20was?= =?utf8?q?=20with=20react=20=E2=80=9Ckey=E2=80=9D=20value=20being=20set=20?= =?utf8?q?based=20on=20array=20index=20-=20RIFT-16249?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I778e7d5043eb9f7288856b8666b2be6e5f8c5a91 Signed-off-by: Bob Gallagher --- .../components/EditDescriptorModelProperties.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js index c1d65be01..01cd5b276 100644 --- a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js +++ b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js @@ -25,6 +25,10 @@ import _includes from 'lodash/includes' import _isArray from 'lodash/isArray' import _cloneDeep from 'lodash/cloneDeep' import _debounce from 'lodash/debounce'; +import _uniqueId from 'lodash/uniqueId'; +import _set from 'lodash/set'; +import _get from 'lodash/get'; +import _has from 'lodash/has'; import utils from '../libraries/utils' import React from 'react' import ClassNames from 'classnames' @@ -50,6 +54,14 @@ import '../styles/EditDescriptorModelProperties.scss' const EMPTY_LEAF_PRESENT = '--empty-leaf-set--'; +function resolveReactKey(value) { + const keyPath = ['uiState', 'fieldKey']; + if (!_has(value, keyPath)) { + _set(value, keyPath, _uniqueId()); + } + return _get(value, keyPath); +} + function getDescriptorMetaBasicForType(type) { const basicPropertiesFilter = d => _includes(DESCRIPTOR_MODEL_FIELDS[type], d.name); return DescriptorModelMetaFactory.getModelMetaForType(type, basicPropertiesFilter) || {properties: []}; @@ -656,7 +668,7 @@ export default function EditDescriptorModelProperties(props) { if (isArray) { valuePath.push(index); - fieldId += index; + fieldId = resolveReactKey(value); } if (isMetaField) { -- 2.25.1