[DevTools] Show fallback in inspected element pane when no element is selected (#35503)

This commit is contained in:
Sebastian "Sebbie" Silbermann
2026-01-15 14:28:02 +01:00
committed by GitHub
parent fae15df40e
commit bb8a76c6cc
7 changed files with 24 additions and 4 deletions

View File

@@ -22,6 +22,7 @@
flex: 1 1 35%;
overflow-x: hidden;
overflow-y: auto;
border-left: 1px solid var(--color-border);
}
.ResizeBarWrapper {
@@ -55,6 +56,7 @@
.InspectedElementWrapper {
flex: 1 1 50%;
border-left: none;
}
.ResizeBar {

View File

@@ -159,7 +159,11 @@ function Components(_: {}) {
<div className={styles.InspectedElementWrapper}>
<NativeStyleContextController>
<InspectedElementErrorBoundary>
<InspectedElement />
<InspectedElement
fallbackEmpty={
'No React element selected. Select an element in the tree to inspect.'
}
/>
</InspectedElementErrorBoundary>
</NativeStyleContextController>
</div>

View File

@@ -3,7 +3,6 @@
flex-direction: column;
height: 100%;
width: 100%;
border-left: 1px solid var(--color-border);
border-top: 1px solid var(--color-border);
}
@@ -69,7 +68,11 @@
padding: 0.25rem;
color: var(--color-dimmer);
font-style: italic;
border-left: 1px solid var(--color-border);
}
.NoInspectionFallback {
padding: 0.25rem;
font-style: italic;
}
.StrictModeNonCompliant {

View File

@@ -36,6 +36,8 @@ import Tooltip from './reach-ui/tooltip';
export type Props = {
actionButtons?: React.Node,
/** fallback to show when no element is inspected */
fallbackEmpty: React.Node,
};
// TODO Make edits and deletes also use transition API!
@@ -44,6 +46,7 @@ const noSourcePromise = Promise.resolve(null);
export default function InspectedElementWrapper({
actionButtons,
fallbackEmpty,
}: Props): React.Node {
const {inspectedElementID} = useContext(TreeStateContext);
const bridge = useContext(BridgeContext);
@@ -193,6 +196,7 @@ export default function InspectedElementWrapper({
return (
<div className={styles.InspectedElement}>
<div className={styles.TitleRow} />
<div className={styles.NoInspectionFallback}>{fallbackEmpty}</div>
</div>
);
}

View File

@@ -25,6 +25,7 @@ function InspectedElementPane() {
<div className={styles.InspectedElementPane}>
<InspectedElement
actionButtons={!hideSettings && <SettingsModalContextToggle />}
fallbackEmpty={"Selected element wasn't rendered with React."}
/>
<SettingsModal />
</div>

View File

@@ -35,6 +35,7 @@
flex: 0 0 calc(100% - var(--horizontal-resize-tree-percentage));
overflow-x: hidden;
overflow-y: auto;
border-left: 1px solid var(--color-border);
}
.ResizeBarWrapper {
@@ -70,6 +71,7 @@
.InspectedElementWrapper {
flex: 0 0 calc(100% - var(--vertical-resize-tree-percentage));
border-left: none;
}
.TreeWrapper + .ResizeBarWrapper .ResizeBar {

View File

@@ -543,7 +543,11 @@ function SuspenseTab(_: {}) {
className={styles.InspectedElementWrapper}
hidden={inspectedElementHidden}>
<InspectedElementErrorBoundary>
<InspectedElement />
<InspectedElement
fallbackEmpty={
'No React element selected. Select a Suspense boundary in the minimap to inspect.'
}
/>
</InspectedElementErrorBoundary>
</div>
<SettingsModal />