diff --git a/packages/entity/src/behavior-components/expression.jsx b/packages/entity/src/behavior-components/expression.jsx index 7c2640d..c26a698 100644 --- a/packages/entity/src/behavior-components/expression.jsx +++ b/packages/entity/src/behavior-components/expression.jsx @@ -38,7 +38,7 @@ const Expression = ({ }); } } - else if (j === ops.length) { + else if (event && j === ops.length) { patches.push({ op: 'add', path: join(path, 'ops', j.toString()), diff --git a/packages/entity/src/behavior-components/expression/key.jsx b/packages/entity/src/behavior-components/expression/key.jsx index 06ab60d..0a6ef2d 100644 --- a/packages/entity/src/behavior-components/expression/key.jsx +++ b/packages/entity/src/behavior-components/expression/key.jsx @@ -35,11 +35,11 @@ const Key = ({ parts.pop(); setCustomization(false); setCustomizationPath('/'); - patch({ - type: 'add', - path: parts.join('/'), - value: 'value' === parts[parts.length - 1] - ? { + if ('value' === parts[parts.length - 1]) { + patch({ + type: 'add', + path: parts.join('/'), + value: { type: 'expression', ops: [ { @@ -47,12 +47,19 @@ const Key = ({ key: customization, }, ], - } - : { - type: 'key', - key: customization, }, - }); + }); + } + else { + patch({ + type: 'add', + path: parts.join('/'), + value: { + type: 'key', + }, + }); + onChange(false, customization, join(parts.join('/'), 'key')); + } }; return (
{ setCustomization(value); }} - onKeyPress={({key}) => { - if ('Enter' === key) { - confirmCustomization(); + onKeyPress={(event) => { + if ('Enter' === event.key) { + confirmCustomization(event); } }} ref={customizeRef}