From ca602bffd03dad07a640cd2ce49f12239a6c1ddf Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 10 Feb 2023 06:04:04 -0800 Subject: [PATCH] Clearer section creation Summary: A bit more explicit with the intent, clearer code. Reviewed By: ivanmisuno Differential Revision: D43186540 fbshipit-source-id: 24f2168f5be91673683966208c9b8b54125aaa5b --- .../sidebar/inspector/AttributesInspector.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/desktop/plugins/public/ui-debugger/components/sidebar/inspector/AttributesInspector.tsx b/desktop/plugins/public/ui-debugger/components/sidebar/inspector/AttributesInspector.tsx index 875036db0..d5cd42553 100644 --- a/desktop/plugins/public/ui-debugger/components/sidebar/inspector/AttributesInspector.tsx +++ b/desktop/plugins/public/ui-debugger/components/sidebar/inspector/AttributesInspector.tsx @@ -258,17 +258,25 @@ export const AttributesInspector: React.FC = ({ const keys = Object.keys(node.attributes); const sections = keys .map(function (key, _) { - const metadataId: number = Number(key); /** * The node top-level attributes refer to the displayable panels. * The panel name is obtained by querying the metadata. * The inspectable contains the actual attributes belonging to each panel. */ + const metadataId: number = Number(key); + const sectionMetadata = metadata.get(metadataId); + if (!sectionMetadata) { + return; + } + const sectionAttributes = node.attributes[ + metadataId + ] as InspectableObject; + return createSection( mode, metadata, - metadata.get(metadataId)?.name ?? '', - node.attributes[metadataId] as InspectableObject, + sectionMetadata.name, + sectionAttributes, ); }) .filter((section) => section !== undefined);