@@ -446,7 +446,7 @@ describe("ObjectField", () => {
446
446
expect ( node . querySelectorAll ( ".field-string" ) ) . to . have . length . of ( 1 ) ;
447
447
} ) ;
448
448
449
- it ( "should apply uiSchema to additionalProperties" , ( ) => {
449
+ it ( "uiSchema title should not affect additionalProperties" , ( ) => {
450
450
const { node } = createFormComponent ( {
451
451
schema,
452
452
uiSchema : {
@@ -459,8 +459,56 @@ describe("ObjectField", () => {
459
459
} ,
460
460
} ) ;
461
461
const labels = node . querySelectorAll ( "label.control-label" ) ;
462
- expect ( labels [ 0 ] . textContent ) . eql ( "CustomName Key" ) ;
463
- expect ( labels [ 1 ] . textContent ) . eql ( "CustomName" ) ;
462
+ expect ( labels [ 0 ] . textContent ) . eql ( "property1 Key" ) ;
463
+ expect ( labels [ 1 ] . textContent ) . eql ( "property1" ) ;
464
+ } ) ;
465
+
466
+ it ( "uiSchema title should update additionalProperties object title" , ( ) => {
467
+ const objectSchema = {
468
+ type : "object" ,
469
+ properties : {
470
+ main : {
471
+ type : "object" ,
472
+ properties : { } ,
473
+ additionalProperties : {
474
+ type : "object" ,
475
+ title : "propTitle" ,
476
+ properties : {
477
+ firstName : {
478
+ type : "string" ,
479
+ title : "First name" ,
480
+ } ,
481
+ } ,
482
+ } ,
483
+ } ,
484
+ } ,
485
+ } ;
486
+
487
+ const { node } = createFormComponent ( {
488
+ schema : objectSchema ,
489
+ uiSchema : {
490
+ main : {
491
+ additionalProperties : {
492
+ "ui:title" : "CustomName" ,
493
+ } ,
494
+ } ,
495
+ } ,
496
+ formData : {
497
+ main : {
498
+ property1 : {
499
+ firstName : "hello" ,
500
+ } ,
501
+ } ,
502
+ } ,
503
+ } ) ;
504
+ const labels = [ ...node . querySelectorAll ( "label.control-label" ) ] . map (
505
+ ( n ) => n . textContent
506
+ ) ;
507
+ expect ( labels ) . to . include ( "property1 Key" ) ;
508
+ const objectTitle = node . querySelector (
509
+ ".form-additional > fieldset > legend"
510
+ ) ;
511
+ expect ( objectTitle . textContent ) . eql ( "CustomName" ) ;
464
512
} ) ;
465
513
466
514
it ( "should not throw validation errors if additionalProperties is undefined" , ( ) => {
0 commit comments