From 4e302d65926cac970a99520a92f5aae69a858a57 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Sat, 25 Apr 2020 18:29:48 +0200 Subject: [PATCH 1/9] Start MVP for showing inspected element key --- .../views/Components/InspectedElementTree.js | 2 +- .../devtools/views/Components/SelectedElement.js | 13 +++++++++++++ .../src/devtools/views/Components/types.js | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js index 6e480a80ed19d..1a0e21829154f 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js @@ -78,7 +78,7 @@ export default function InspectedElementTree({ return (
-
{label}
+ {label &&
{label}
} {!isEmpty && ( - )} -
+ {label && ( +
+
{label}
+ {!isEmpty && ( + + )} +
+ )} {isEmpty && !canAddEntries &&
None
} {!isEmpty && (entries: any).map(([name, value]) => ( From 1122194002eb93845eaa2dbf77d695b46cd3f3bb Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Sun, 26 Apr 2020 10:20:54 +0200 Subject: [PATCH 6/9] Move above props --- .../devtools/views/Components/SelectedElement.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js index 8bbc39cde8108..6dca4af203829 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js @@ -376,6 +376,14 @@ function InspectedElementView({
+ {key && ( + + )} - {type === ElementTypeSuspense ? ( Date: Mon, 11 May 2020 11:55:17 -0700 Subject: [PATCH 7/9] Revert changes to InspectedElementTree.js --- .../views/Components/InspectedElementTree.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js index 43f00dede92c7..6e480a80ed19d 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementTree.js @@ -77,16 +77,14 @@ export default function InspectedElementTree({ } else { return (
- {label && ( -
-
{label}
- {!isEmpty && ( - - )} -
- )} +
+
{label}
+ {!isEmpty && ( + + )} +
{isEmpty && !canAddEntries &&
None
} {!isEmpty && (entries: any).map(([name, value]) => ( From d61fbdc1db42b4ee6a04e28ee7d2f825419d724a Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Mon, 11 May 2020 11:55:40 -0700 Subject: [PATCH 8/9] Move key to left of component name --- .../views/Components/SelectedElement.js | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js index 6dca4af203829..40f45334e61d5 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js @@ -190,6 +190,15 @@ export default function SelectedElement(_: Props) { return (
+ {element.key && ( + <> +
+ {element.key} +
+
+ + )} +
{element.displayName} @@ -284,7 +293,6 @@ function InspectedElementView({ props, source, state, - key, } = inspectedElement; const {ownerID} = useContext(TreeStateContext); @@ -302,12 +310,6 @@ function InspectedElementView({ }, [getInspectedElementPath, id], ); - const inspectKeyPath = useCallback( - (path: Array) => { - getInspectedElementPath(id, ['key', ...path]); - }, - [getInspectedElementPath, id], - ); const inspectPropsPath = useCallback( (path: Array) => { getInspectedElementPath(id, ['props', ...path]); @@ -376,14 +378,6 @@ function InspectedElementView({
- {key && ( - - )} Date: Mon, 11 May 2020 11:58:01 -0700 Subject: [PATCH 9/9] Updated CSS --- .../views/Components/SelectedElement.css | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.css b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.css index eaf5ac4a33a3c..377a428e96cfc 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.css +++ b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.css @@ -16,10 +16,37 @@ padding: 0.5rem; } +.Key { + flex: 0 1 auto; + padding-left: 0.25rem; + padding-right: 0.125rem; + line-height: 1rem; + border-top-left-radius: 0.125rem; + border-bottom-left-radius: 0.125rem; + display: inline-block; + background-color: var(--color-component-badge-background); + color: var(--color-text); + font-family: var(--font-family-monospace); + font-size: var(--font-size-monospace-small); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 100%; +} + +.KeyArrow { + height: 1rem; + width: 1rem; + margin-right: -0.25rem; + border: 0.5rem solid transparent; + border-left: 0.5rem solid var(--color-component-badge-background); +} + .SelectedComponentName { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; + line-height: normal; } .Owners {