Skip to content

Commit 5b41bc0

Browse files
committed
[DevTools] Show Transition indicator when "suspended by" rows are expanded
1 parent cad813a commit 5b41bc0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSharedStyles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
display: flex;
7676
}
7777

78+
.CollapsableHeader[data-pending="true"] {
79+
cursor: progress;
80+
}
81+
7882
.CollapsableHeaderIcon {
7983
flex: 0 0 1rem;
8084
margin-left: -0.25rem;

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import {copy} from 'clipboard-js';
1111
import * as React from 'react';
12-
import {useState} from 'react';
12+
import {useState, useTransition} from 'react';
1313
import Button from '../Button';
1414
import ButtonIcon from '../ButtonIcon';
1515
import KeyValue from './KeyValue';
@@ -101,6 +101,7 @@ function SuspendedByRow({
101101
maxTime,
102102
}: RowProps) {
103103
const [isOpen, setIsOpen] = useState(false);
104+
const [openIsPending, startOpenTransition] = useTransition();
104105
const ioInfo = asyncInfo.awaited;
105106
const name = useInferredName(asyncInfo);
106107
const description = ioInfo.description;
@@ -144,7 +145,14 @@ function SuspendedByRow({
144145
<div className={styles.CollapsableRow}>
145146
<Button
146147
className={styles.CollapsableHeader}
147-
onClick={() => setIsOpen(prevIsOpen => !prevIsOpen)}
148+
data-pending={openIsPending}
149+
onClick={() => {
150+
startOpenTransition(() => {
151+
setIsOpen(prevIsOpen => !prevIsOpen);
152+
});
153+
}}
154+
// Changing the title on pending transition will not be visible since
155+
// (Reach?) tooltips are dismissed on activation.
148156
title={
149157
longName +
150158
' — ' +

0 commit comments

Comments
 (0)