From: Bob Gallagher Date: Wed, 19 Apr 2017 19:44:11 +0000 (-0400) Subject: Fix problem where the connection-point UI was not updating list correctly when button... X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F1592%2F2;p=osm%2FUI.git Fix problem where the connection-point UI was not updating list correctly when button clicked to deleted a cp. - this would actually apply to any “list” - issue was with react “key” value being set based on array index - RIFT-16249 Change-Id: I778e7d5043eb9f7288856b8666b2be6e5f8c5a91 Signed-off-by: Bob Gallagher --- 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) {