diff --git a/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js b/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js index af9e4b27e6181..89342ccffc1f1 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js @@ -210,6 +210,13 @@ export default function KeyValue({ canRenameTheCurrentPath = canRenamePathsAtDepth(depth); } + const hasChildren = + typeof value === 'object' && + value !== null && + (canEditValues || + (isArray(value) && value.length > 0) || + Object.entries(value).length > 0); + let renderedName; if (isDirectChildOfAnArray) { if (canDeletePaths) { @@ -218,27 +225,37 @@ export default function KeyValue({ ); } else { renderedName = ( - + {name} {!!hookName && ({hookName})} + : ); } } else if (canRenameTheCurrentPath) { renderedName = ( - + <> + + : + ); } else { renderedName = ( - + {name} {!!hookName && ({hookName})} + : ); } @@ -286,7 +303,6 @@ export default function KeyValue({ style={style}>
{renderedName} -
:
{canEditValues ? (
{renderedName} -
:
{ @@ -365,7 +380,6 @@ export default function KeyValue({
)} {renderedName} -
:
@@ -388,7 +402,6 @@ export default function KeyValue({ } } else { if (isArray(value)) { - const hasChildren = value.length > 0 || canEditValues; const displayName = getMetaValueLabel(value); children = value.map((innerValue, index) => ( @@ -449,12 +462,11 @@ export default function KeyValue({ ref={contextMenuTriggerRef} style={style}> {hasChildren ? ( - + ) : (
)} {renderedName} -
:
@@ -472,7 +484,6 @@ export default function KeyValue({ entries.sort(alphaSortEntries); } - const hasChildren = entries.length > 0 || canEditValues; const displayName = getMetaValueLabel(value); children = entries.map(([key, keyValue]): ReactElement => ( @@ -531,12 +542,11 @@ export default function KeyValue({ ref={contextMenuTriggerRef} style={style}> {hasChildren ? ( - + ) : (
)} {renderedName} -
:
@@ -567,7 +577,10 @@ function DeleteToggle({deletePath, name, path}) { title="Delete entry"> - {name} + + {name} + : + ); }