mirror of
https://github.com/facebook/react.git
synced 2026-02-23 12:13:04 +00:00
[DevTools] Show fallback in inspected element pane when no element is selected (#35503)
This commit is contained in:
committed by
GitHub
parent
fae15df40e
commit
bb8a76c6cc
@@ -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 {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ function InspectedElementPane() {
|
||||
<div className={styles.InspectedElementPane}>
|
||||
<InspectedElement
|
||||
actionButtons={!hideSettings && <SettingsModalContextToggle />}
|
||||
fallbackEmpty={"Selected element wasn't rendered with React."}
|
||||
/>
|
||||
<SettingsModal />
|
||||
</div>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 />
|
||||
|
||||
Reference in New Issue
Block a user