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({
op: 'add',
path: join(path, 'ops', j.toString()),

View File

@ -35,11 +35,11 @@ const Key = ({
parts.pop();
setCustomization(false);
setCustomizationPath('/');
if ('value' === parts[parts.length - 1]) {
patch({
type: 'add',
path: parts.join('/'),
value: 'value' === parts[parts.length - 1]
? {
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 (
<div
@ -101,9 +108,9 @@ const Key = ({
onChange={({target: {value}}) => {
setCustomization(value);
}}
onKeyPress={({key}) => {
if ('Enter' === key) {
confirmCustomization();
onKeyPress={(event) => {
if ('Enter' === event.key) {
confirmCustomization(event);
}
}}
ref={customizeRef}