diff --git a/idom/client/app/core_modules/layout.js b/idom/client/app/core_modules/layout.js index 439b0c9a1..4ab169590 100644 --- a/idom/client/app/core_modules/layout.js +++ b/idom/client/app/core_modules/layout.js @@ -193,17 +193,34 @@ function useInplaceJsonPatch(doc) { const applyPatch = react.useCallback( (path, patch) => { - jsonpatch.applyPatch( - jsonpatch.getValueByPointer(ref.current, path), - patch - ); + applyPatchInplace(ref.current, path, patch); forceUpdate(); }, [ref, forceUpdate] ); + return [ref.current, applyPatch]; } +function applyPatchInplace(doc, path, patch) { + if (!path) { + jsonpatch.applyPatch(doc, patch); + } else { + jsonpatch.applyPatch(doc, [ + { + op: "replace", + path: path, + value: jsonpatch.applyPatch( + jsonpatch.getValueByPointer(doc, path), + patch, + false, + false + ).newDocument, + }, + ]); + } +} + function useForceUpdate() { const [, updateState] = react.useState(); return react.useCallback(() => updateState({}), []);