fix: assgnment & parent key buildup

This commit is contained in:
cha0s 2021-01-31 00:17:10 -06:00
parent 4467281f87
commit aa5a4e4c97
2 changed files with 21 additions and 14 deletions

View File

@ -38,7 +38,7 @@ const Expression = ({
}); });
} }
} }
else if (j === ops.length) { else if (event && j === ops.length) {
patches.push({ patches.push({
op: 'add', op: 'add',
path: join(path, 'ops', j.toString()), path: join(path, 'ops', j.toString()),

View File

@ -35,11 +35,11 @@ const Key = ({
parts.pop(); parts.pop();
setCustomization(false); setCustomization(false);
setCustomizationPath('/'); setCustomizationPath('/');
patch({ if ('value' === parts[parts.length - 1]) {
type: 'add', patch({
path: parts.join('/'), type: 'add',
value: 'value' === parts[parts.length - 1] path: parts.join('/'),
? { value: {
type: 'expression', type: 'expression',
ops: [ ops: [
{ {
@ -47,12 +47,19 @@ const Key = ({
key: customization, key: customization,
}, },
], ],
}
: {
type: 'key',
key: customization,
}, },
}); });
}
else {
patch({
type: 'add',
path: parts.join('/'),
value: {
type: 'key',
},
});
onChange(false, customization, join(parts.join('/'), 'key'));
}
}; };
return ( return (
<div <div
@ -101,9 +108,9 @@ const Key = ({
onChange={({target: {value}}) => { onChange={({target: {value}}) => {
setCustomization(value); setCustomization(value);
}} }}
onKeyPress={({key}) => { onKeyPress={(event) => {
if ('Enter' === key) { if ('Enter' === event.key) {
confirmCustomization(); confirmCustomization(event);
} }
}} }}
ref={customizeRef} ref={customizeRef}