@@ -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 = (
@@ -269,18 +275,19 @@ export const coreReducer: Reducer<JsonFormsCore, CoreActions> = (
269275 errors,
270276 } ;
271277 } else {
272- const oldData : any = get ( state . data , action . path ) ;
278+ const lodashDataPathSegments = toLodashSegments ( action . path ) ;
279+ const oldData : any = get ( state . data , lodashDataPathSegments ) ;
273280 const newData = action . updater ( cloneDeep ( oldData ) ) ;
274281 let newState : any ;
275282 if ( newData !== undefined ) {
276283 newState = setFp (
277- action . path ,
284+ lodashDataPathSegments ,
278285 newData ,
279286 state . data === undefined ? { } : state . data
280287 ) ;
281288 } else {
282289 newState = unsetFp (
283- action . path ,
290+ lodashDataPathSegments ,
284291 state . data === undefined ? { } : state . data
285292 ) ;
286293 }
@@ -352,19 +359,11 @@ export const getControlPath = (error: ErrorObject) => {
352359 // With AJV v8 the property was renamed to 'instancePath'
353360 let controlPath = ( error as any ) . dataPath || error . instancePath || '' ;
354361
355- // change '/' chars to '.'
356- controlPath = controlPath . replace ( / \/ / g, '.' ) ;
357-
358362 const invalidProperty = getInvalidProperty ( error ) ;
359363 if ( invalidProperty !== undefined && ! controlPath . endsWith ( invalidProperty ) ) {
360- controlPath = ` ${ controlPath } . ${ invalidProperty } ` ;
364+ controlPath = composePaths ( controlPath , invalidProperty ) ;
361365 }
362366
363- // remove '.' chars at the beginning of paths
364- controlPath = controlPath . replace ( / ^ ./ , '' ) ;
365-
366- // decode JSON Pointer escape sequences
367- controlPath = decode ( controlPath ) ;
368367 return controlPath ;
369368} ;
370369
@@ -462,5 +461,5 @@ export const errorAt = (instancePath: string, schema: JsonSchema) =>
462461 getErrorsAt ( instancePath , schema , ( path ) => path === instancePath ) ;
463462export const subErrorsAt = ( instancePath : string , schema : JsonSchema ) =>
464463 getErrorsAt ( instancePath , schema , ( path ) =>
465- path . startsWith ( instancePath + '. ' )
464+ path . startsWith ( instancePath + '/ ' )
466465 ) ;
0 commit comments