@@ -46,7 +46,13 @@ import {
4646 UPDATE_CORE ,
4747 UpdateCoreAction ,
4848} from '../actions' ;
49- import { createAjv , decode , isOneOfEnumSchema , Reducer } from '../util' ;
49+ import {
50+ composePaths ,
51+ createAjv ,
52+ isOneOfEnumSchema ,
53+ Reducer ,
54+ toLodashSegments ,
55+ } from '../util' ;
5056import type { JsonSchema , UISchemaElement } from '../models' ;
5157
5258export const validate = (
@@ -284,18 +290,19 @@ export const coreReducer: Reducer<JsonFormsCore, CoreActions> = (
284290 errors,
285291 } ;
286292 } else {
287- const oldData : any = get ( state . data , action . path ) ;
293+ const lodashDataPathSegments = toLodashSegments ( action . path ) ;
294+ const oldData : any = get ( state . data , lodashDataPathSegments ) ;
288295 const newData = action . updater ( cloneDeep ( oldData ) ) ;
289296 let newState : any ;
290297 if ( newData !== undefined ) {
291298 newState = setFp (
292- action . path ,
299+ lodashDataPathSegments ,
293300 newData ,
294301 state . data === undefined ? { } : state . data
295302 ) ;
296303 } else {
297304 newState = unsetFp (
298- action . path ,
305+ lodashDataPathSegments ,
299306 state . data === undefined ? { } : state . data
300307 ) ;
301308 }
@@ -369,19 +376,11 @@ export const getControlPath = (error: ErrorObject) => {
369376 // With AJV v8 the property was renamed to 'instancePath'
370377 let controlPath = ( error as any ) . dataPath || error . instancePath || '' ;
371378
372- // change '/' chars to '.'
373- controlPath = controlPath . replace ( / \/ / g, '.' ) ;
374-
375379 const invalidProperty = getInvalidProperty ( error ) ;
376380 if ( invalidProperty !== undefined && ! controlPath . endsWith ( invalidProperty ) ) {
377- controlPath = ` ${ controlPath } . ${ invalidProperty } ` ;
381+ controlPath = composePaths ( controlPath , invalidProperty ) ;
378382 }
379383
380- // remove '.' chars at the beginning of paths
381- controlPath = controlPath . replace ( / ^ ./ , '' ) ;
382-
383- // decode JSON Pointer escape sequences
384- controlPath = decode ( controlPath ) ;
385384 return controlPath ;
386385} ;
387386
@@ -479,5 +478,5 @@ export const errorAt = (instancePath: string, schema: JsonSchema) =>
479478 getErrorsAt ( instancePath , schema , ( path ) => path === instancePath ) ;
480479export const subErrorsAt = ( instancePath : string , schema : JsonSchema ) =>
481480 getErrorsAt ( instancePath , schema , ( path ) =>
482- path . startsWith ( instancePath + '. ' )
481+ path . startsWith ( instancePath + '/ ' )
483482 ) ;
0 commit comments