From aa5a4e4c971743313634c0e64802ead29caafaf2 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 31 Jan 2021 00:17:10 -0600 Subject: [PATCH] fix: assgnment & parent key buildup --- .../src/behavior-components/expression.jsx | 2 +- .../behavior-components/expression/key.jsx | 33 +++++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) 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}