Fix problem where the connection-point UI was not updating list correctly when button...
authorBob Gallagher <bob.gallagher@riftio.com>
Wed, 19 Apr 2017 19:44:11 +0000 (15:44 -0400)
committerBob Gallagher <bob.gallagher@riftio.com>
Thu, 20 Apr 2017 11:42:43 +0000 (07:42 -0400)
- 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 <bob.gallagher@riftio.com>
skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js

index c1d65be..01cd5b2 100644 (file)
@@ -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) {