From 115cb1af711e0e1d5094e8c733c6a4bdee4866a0 Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Thu, 26 Oct 2023 05:24:30 -0700 Subject: [PATCH] Dont show empty subsections Summary: changelog: UIDebugger - new sidebar design Reviewed By: lblasa Differential Revision: D50653551 fbshipit-source-id: 8a173abb033f35ba6abd2d5f417e647ca2ffe8e7 --- .../sidebarV2/AttributesInspector.tsx | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/desktop/plugins/public/ui-debugger/components/sidebarV2/AttributesInspector.tsx b/desktop/plugins/public/ui-debugger/components/sidebarV2/AttributesInspector.tsx index 61abfdde8..12d246bf5 100644 --- a/desktop/plugins/public/ui-debugger/components/sidebarV2/AttributesInspector.tsx +++ b/desktop/plugins/public/ui-debugger/components/sidebarV2/AttributesInspector.tsx @@ -224,30 +224,36 @@ function SubSection({ metadataMap: MetadataMap; onDisplayModal: (modaldata: ModalData) => void; }) { + const children = Object.entries(inspectableObject.fields).map( + ([key, value]) => { + const metadataId: number = Number(key); + const attributeMetadata = metadataMap.get(metadataId); + if (attributeMetadata == null) { + return null; + } + const attributeName = + upperFirst(attributeMetadata?.name) ?? String(metadataId); + + return ( + + ); + }, + ); + if (children.length === 0) { + return null; + } return ( {attributeName} - {Object.entries(inspectableObject.fields).map(([key, value]) => { - const metadataId: number = Number(key); - const attributeMetadata = metadataMap.get(metadataId); - if (attributeMetadata == null) { - return null; - } - const attributeName = - upperFirst(attributeMetadata?.name) ?? String(metadataId); - - return ( - - ); - })} + {children} ); }