Skip to content

Commit b56907d

Browse files
authored
[DevTools] Show Props as Read-only for Suspense/Activity but below (#34695)
Somehow my last commit didn't make it in #34630.
1 parent c825f03 commit b56907d

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import styles from './InspectedElementSharedStyles.css';
2020
import {
2121
ElementTypeClass,
2222
ElementTypeSuspense,
23+
ElementTypeActivity,
2324
} from 'react-devtools-shared/src/frontend/types';
2425
import {withPermissionsCheck} from 'react-devtools-shared/src/frontend/utils/withPermissionsCheck';
2526

@@ -50,20 +51,15 @@ export default function InspectedElementPropsTree({
5051
type,
5152
} = inspectedElement;
5253

53-
if (type === ElementTypeSuspense) {
54-
// Skip showing the props for Suspense. We want to give more real estate to the
55-
// "Suspended by" for Suspense boundaries. We could maybe show it further below
56-
// but in practice, the props of Suspense boundaries are not very useful to
57-
// inspect because the name shows in the tree already. The children in the tree
58-
// will be either the "fallback" or "children" prop which you can already inspect
59-
// but resuspending the tree.
60-
return null;
61-
}
62-
6354
const canDeletePaths =
6455
type === ElementTypeClass || canEditFunctionPropsDeletePaths;
6556
const canEditValues =
66-
!readOnly && (type === ElementTypeClass || canEditFunctionProps);
57+
!readOnly &&
58+
(type === ElementTypeClass || canEditFunctionProps) &&
59+
// Make it read-only for Suspense to make it a bit cleaner. It's not
60+
// useful to edit children anyway.
61+
type !== ElementTypeSuspense &&
62+
type !== ElementTypeActivity;
6763
const canRenamePaths =
6864
type === ElementTypeClass || canEditFunctionPropsRenamePaths;
6965

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementView.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import InspectedElementSourcePanel from './InspectedElementSourcePanel';
2424
import StackTraceView from './StackTraceView';
2525
import OwnerView from './OwnerView';
2626
import Skeleton from './Skeleton';
27+
import {
28+
ElementTypeSuspense,
29+
ElementTypeActivity,
30+
} from 'react-devtools-shared/src/frontend/types';
2731

2832
import styles from './InspectedElementView.css';
2933

@@ -60,6 +64,7 @@ export default function InspectedElementView({
6064
rootType,
6165
source,
6266
nativeTag,
67+
type,
6368
} = inspectedElement;
6469

6570
const bridge = useContext(BridgeContext);
@@ -74,6 +79,17 @@ export default function InspectedElementView({
7479
const showRenderedBy =
7580
showStack || showOwnersList || rendererLabel !== null || rootType !== null;
7681

82+
const propsSection = (
83+
<div className={styles.InspectedElementSection}>
84+
<InspectedElementPropsTree
85+
bridge={bridge}
86+
element={element}
87+
inspectedElement={inspectedElement}
88+
store={store}
89+
/>
90+
</div>
91+
);
92+
7793
return (
7894
<Fragment>
7995
<div className={styles.InspectedElement}>
@@ -85,14 +101,12 @@ export default function InspectedElementView({
85101
/>
86102
</div>
87103

88-
<div className={styles.InspectedElementSection}>
89-
<InspectedElementPropsTree
90-
bridge={bridge}
91-
element={element}
92-
inspectedElement={inspectedElement}
93-
store={store}
94-
/>
95-
</div>
104+
{
105+
// For Suspense and Activity we show the props further down.
106+
type !== ElementTypeSuspense && type !== ElementTypeActivity
107+
? propsSection
108+
: null
109+
}
96110

97111
<div className={styles.InspectedElementSection}>
98112
<InspectedElementStateTree
@@ -157,6 +171,13 @@ export default function InspectedElementView({
157171
/>
158172
</div>
159173

174+
{
175+
// For Suspense and Activity we show the props below suspended by to give that more priority.
176+
type !== ElementTypeSuspense && type !== ElementTypeActivity
177+
? null
178+
: propsSection
179+
}
180+
160181
{showRenderedBy && (
161182
<div
162183
className={styles.InspectedElementSection}

0 commit comments

Comments
 (0)