|
9 | 9 |
|
10 | 10 | import {copy} from 'clipboard-js'; |
11 | 11 | import * as React from 'react'; |
12 | | -import {useState} from 'react'; |
| 12 | +import {useState, useTransition} from 'react'; |
13 | 13 | import Button from '../Button'; |
14 | 14 | import ButtonIcon from '../ButtonIcon'; |
15 | 15 | import KeyValue from './KeyValue'; |
@@ -101,6 +101,7 @@ function SuspendedByRow({ |
101 | 101 | maxTime, |
102 | 102 | }: RowProps) { |
103 | 103 | const [isOpen, setIsOpen] = useState(false); |
| 104 | + const [openIsPending, startOpenTransition] = useTransition(); |
104 | 105 | const ioInfo = asyncInfo.awaited; |
105 | 106 | const name = useInferredName(asyncInfo); |
106 | 107 | const description = ioInfo.description; |
@@ -144,7 +145,16 @@ function SuspendedByRow({ |
144 | 145 | <div className={styles.CollapsableRow}> |
145 | 146 | <Button |
146 | 147 | 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. |
148 | 158 | title={ |
149 | 159 | longName + |
150 | 160 | ' — ' + |
|
0 commit comments