Skip to content

Commit 8a24ef3

Browse files
authored
[DevTools] Show Transition indicator when "suspended by" rows are expanded (facebook#34565)
1 parent c552618 commit 8a24ef3

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-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: 12 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,16 @@ function SuspendedByRow({
144145
<div className={styles.CollapsableRow}>
145146
<Button
146147
className={styles.CollapsableHeader}
147-
onClick={() => setIsOpen(prevIsOpen => !prevIsOpen)}
148+
// TODO: May be better to leave to React's default Transition indicator.
149+
// Though no apps implement this option at the moment.
150+
data-pending={openIsPending}
151+
onClick={() => {
152+
startOpenTransition(() => {
153+
setIsOpen(prevIsOpen => !prevIsOpen);
154+
});
155+
}}
156+
// Changing the title on pending transition will not be visible since
157+
// (Reach?) tooltips are dismissed on activation.
148158
title={
149159
longName +
150160
' — ' +

0 commit comments

Comments
 (0)