Skip to content

Commit 14b1d6a

Browse files
committed
Make the Initial Paint clickable to select the root
1 parent 0fe3caf commit 14b1d6a

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseBreadcrumbs.css

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111
display: inline;
1212
}
1313

14-
.SuspenseBreadcrumbsText {
15-
font-family: var(--font-family-monospace);
16-
font-size: var(--font-size-monospace-normal);
17-
padding: 0.25rem;
18-
white-space: nowrap;
19-
}
20-
2114
.SuspenseBreadcrumbsListItem[aria-current="true"] .SuspenseBreadcrumbsButton {
2215
color: var(--color-button-active);
2316
}

packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseBreadcrumbs.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export default function SuspenseBreadcrumbs(): React$Node {
2525
const store = useContext(StoreContext);
2626
const treeDispatch = useContext(TreeDispatcherContext);
2727
const suspenseTreeDispatch = useContext(SuspenseTreeDispatcherContext);
28-
const {selectedSuspenseID, lineage} = useContext(SuspenseTreeStateContext);
28+
const {selectedSuspenseID, selectedRootID, lineage} = useContext(
29+
SuspenseTreeStateContext,
30+
);
2931

3032
const {highlightHostInstance, clearHighlightHostInstance} =
3133
useHighlightHostInstance();
@@ -43,9 +45,20 @@ export default function SuspenseBreadcrumbs(): React$Node {
4345
// that rendered the whole screen. In laymans terms this is really "Initial Paint".
4446
// TODO: Once we add subtree selection, then the equivalent should be called
4547
// "Transition" since in that case it's really about a Transition within the page.
46-
<li className={styles.SuspenseBreadcrumbsListItem}>
47-
<span className={styles.SuspenseBreadcrumbsText}>Initial Paint</span>
48-
</li>
48+
selectedRootID !== null ? (
49+
<li
50+
className={styles.SuspenseBreadcrumbsListItem}
51+
aria-current={selectedSuspenseID === selectedRootID}
52+
onPointerEnter={highlightHostInstance.bind(null, selectedRootID)}
53+
onPointerLeave={clearHighlightHostInstance}>
54+
<button
55+
className={styles.SuspenseBreadcrumbsButton}
56+
onClick={handleClick.bind(null, selectedRootID)}
57+
type="button">
58+
Initial Paint
59+
</button>
60+
</li>
61+
) : null
4962
) : (
5063
lineage.map((id, index) => {
5164
const node = store.getSuspenseByID(id);

0 commit comments

Comments
 (0)