@@ -446,6 +446,73 @@ describe('ViewFlattening', () => {
446446 /> ,
447447 ) ;
448448 } ) ;
449+
450+ test ( '#58647: child with negative zIndex is kept when its parent flattens and its grandparent unflattens' , ( ) => {
451+ const root = Fantom . createRoot ( ) ;
452+
453+ function render ( opacityOnGrandparent : boolean ) {
454+ Fantom . runTask ( ( ) => {
455+ root . render (
456+ < View nativeID = "Q" style = { { opacity : 0.5 } } >
457+ < View style = { opacityOnGrandparent ? { opacity : 0.5 } : null } >
458+ < View style = { opacityOnGrandparent ? null : { opacity : 0.5 } } >
459+ < View nativeID = "A" />
460+ < View nativeID = "K" style = { { zIndex : - 1 } } />
461+ < View nativeID = "B" />
462+ </ View >
463+ </ View >
464+ </ View > ,
465+ ) ;
466+ } ) ;
467+ }
468+
469+ const expectedOutput = (
470+ < rn-view nativeID = "Q" >
471+ < rn-view >
472+ < rn-view key = "0" nativeID = "K" />
473+ < rn-view key = "1" nativeID = "A" />
474+ < rn-view key = "2" nativeID = "B" />
475+ </ rn-view >
476+ </ rn-view >
477+ ) ;
478+
479+ render ( false ) ;
480+ root . takeMountingManagerLogs ( ) ;
481+
482+ render ( true ) ;
483+ expect ( root . takeMountingManagerLogs ( ) ) . toEqual ( [
484+ 'Remove {type: "View", parentNativeID: "Q", index: 0, nativeID: (N/A)}' ,
485+ 'Remove {type: "View", parentNativeID: (N/A), index: 2, nativeID: "B"}' ,
486+ 'Remove {type: "View", parentNativeID: (N/A), index: 1, nativeID: "A"}' ,
487+ 'Remove {type: "View", parentNativeID: (N/A), index: 0, nativeID: "K"}' ,
488+ 'Delete {type: "View", nativeID: (N/A)}' ,
489+ 'Create {type: "View", nativeID: (N/A)}' ,
490+ 'Insert {type: "View", parentNativeID: "Q", index: 0, nativeID: (N/A)}' ,
491+ 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "K"}' ,
492+ 'Insert {type: "View", parentNativeID: (N/A), index: 1, nativeID: "A"}' ,
493+ 'Insert {type: "View", parentNativeID: (N/A), index: 2, nativeID: "B"}' ,
494+ ] ) ;
495+ expect ( root . getRenderedOutput ( { props : [ 'nativeID' ] } ) . toJSX ( ) ) . toEqual (
496+ expectedOutput ,
497+ ) ;
498+
499+ render ( false ) ;
500+ expect ( root . takeMountingManagerLogs ( ) ) . toEqual ( [
501+ 'Remove {type: "View", parentNativeID: (N/A), index: 2, nativeID: "B"}' ,
502+ 'Remove {type: "View", parentNativeID: (N/A), index: 1, nativeID: "A"}' ,
503+ 'Remove {type: "View", parentNativeID: (N/A), index: 0, nativeID: "K"}' ,
504+ 'Remove {type: "View", parentNativeID: "Q", index: 0, nativeID: (N/A)}' ,
505+ 'Delete {type: "View", nativeID: (N/A)}' ,
506+ 'Create {type: "View", nativeID: (N/A)}' ,
507+ 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "K"}' ,
508+ 'Insert {type: "View", parentNativeID: (N/A), index: 1, nativeID: "A"}' ,
509+ 'Insert {type: "View", parentNativeID: (N/A), index: 2, nativeID: "B"}' ,
510+ 'Insert {type: "View", parentNativeID: "Q", index: 0, nativeID: (N/A)}' ,
511+ ] ) ;
512+ expect ( root . getRenderedOutput ( { props : [ 'nativeID' ] } ) . toJSX ( ) ) . toEqual (
513+ expectedOutput ,
514+ ) ;
515+ } ) ;
449516} ) ;
450517
451518describe ( 'reconciliation of setNativeProps and React commit' , ( ) => {
0 commit comments