File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ import {
7373 isVisible ,
7474 Resolve ,
7575 resolveSchema ,
76+ decode ,
7677} from '../util' ;
7778import {
7879 Translator ,
@@ -114,7 +115,7 @@ const isRequired = (
114115 rootSchema : JsonSchema
115116) : boolean => {
116117 const pathSegments = schemaPath . split ( '/' ) ;
117- const lastSegment = pathSegments [ pathSegments . length - 1 ] ;
118+ const lastSegment = decode ( pathSegments [ pathSegments . length - 1 ] ) ;
118119 // Skip "properties", "items" etc. to resolve the parent
119120 const nextHigherSchemaSegments = pathSegments . slice (
120121 0 ,
Original file line number Diff line number Diff line change @@ -1871,6 +1871,38 @@ test('mapStateToControlProps - i18n errors - custom keyword wins over all other
18711871 t . is ( props . errors , 'this is my error custom error message' ) ;
18721872} ) ;
18731873
1874+ test ( 'mapStateToControlProps - required is calculated correctly from encoded JSON Pointer' , ( t ) => {
1875+ const uischema : ControlElement = {
1876+ type : 'Control' ,
1877+ scope : '#/properties/~1firstName' ,
1878+ } ;
1879+ const schema = {
1880+ type : 'object' ,
1881+ properties : {
1882+ '/firstName' : { type : 'string' } ,
1883+ } ,
1884+ required : [ '/firstName' ] ,
1885+ } ;
1886+ const ownProps = {
1887+ visible : true ,
1888+ uischema,
1889+ path : 'foo' ,
1890+ schema,
1891+ } ;
1892+ const state = {
1893+ jsonforms : {
1894+ core : {
1895+ schema,
1896+ data : { } ,
1897+ uischema,
1898+ errors : [ ] as ErrorObject [ ] ,
1899+ } ,
1900+ } ,
1901+ } ;
1902+ const props = mapStateToControlProps ( state , ownProps ) ;
1903+ t . true ( props . required === true ) ;
1904+ } ) ;
1905+
18741906test ( 'mapStateToEnumControlProps - i18n - should not crash without i18n' , ( t ) => {
18751907 const ownProps = {
18761908 uischema : coreUISchema ,
You can’t perform that action at this time.
0 commit comments