diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.mm index b39ed7be9..966528d8a 100644 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.mm +++ b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutDescriptor.mm @@ -86,6 +86,9 @@ - (id)childForNode:(SKComponentLayoutWrapper *)node atIndex:(NSUInteger)index { if (node.children.size() == 0) { + if (node.rootNode == node.component.viewContext.view) { + return nil; + } return node.component.viewContext.view; } return node.children[index]; diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.h b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.h index a7d4c8da4..5f7513fe1 100644 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.h +++ b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.h @@ -18,7 +18,7 @@ @property (nonatomic, readonly) CGSize size; @property (nonatomic, readonly) CGPoint position; @property (nonatomic, readonly) std::vector children; - +@property (nonatomic, readonly) id rootNode; // Null for layouts which are not direct children of a CKFlexboxComponent @property (nonatomic, readonly) BOOL isFlexboxChild; @property (nonatomic, readonly) CKFlexboxComponentChild flexboxChild; diff --git a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.mm b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.mm index b6d9999bd..4fded345c 100644 --- a/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.mm +++ b/iOS/Plugins/FlipperKitLayoutPlugin/FlipperKitLayoutComponentKitSupport/SKComponentLayoutWrapper.mm @@ -58,7 +58,8 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo [[SKComponentLayoutWrapper alloc] initWithLayout:layout position:CGPointMake(0, 0) parentKey:[NSString stringWithFormat: @"%p.", layout.component] - reuseWrapper:reuseWrapper]; + reuseWrapper:reuseWrapper + rootNode: root]; // Cache the result. if (layout.component) { objc_setAssociatedObject(layout.component, &kLayoutWrapperKey, wrapper, OBJC_ASSOCIATION_RETAIN_NONATOMIC); @@ -70,8 +71,10 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo position:(CGPoint)position parentKey:(NSString *)parentKey reuseWrapper:(CKComponentReuseWrapper *)reuseWrapper + rootNode:(id)node { if (self = [super init]) { + _rootNode = node; _component = layout.component; _size = layout.size; _position = position; @@ -93,7 +96,9 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo SKComponentLayoutWrapper *childWrapper = [[SKComponentLayoutWrapper alloc] initWithLayout:child.layout position:child.position parentKey:[_identifier stringByAppendingFormat:@"[%d].", index++] - reuseWrapper:reuseWrapper]; + reuseWrapper:reuseWrapper + rootNode: nil + ]; childWrapper->_isFlexboxChild = [_component isKindOfClass:[CKFlexboxComponent class]]; childWrapper->_flexboxChild = findFlexboxLayoutParams(_component, child.layout.component); _children.push_back(childWrapper);