@@ -481,18 +481,16 @@ export function Wires({ className }: { className?: string }) {
481
481
const [ step , inc ] = useReducer ( x => ( x + 1 ) % STEPS , 0 )
482
482
483
483
const ref = useRef < SVGSVGElement > ( null )
484
-
485
- // set to true by manual interaction: we skip the next animation end
486
- // if the animation finishes right after the user's click
487
- const shouldAvoidDoubleSpin = useRef ( false )
484
+ const backgroundRef = useRef < HTMLButtonElement > ( null )
488
485
489
486
useEffect ( ( ) => {
490
487
const animate = document . querySelector (
491
488
"#paint_sr_pri_highlight_linear_671_9150 animate" ,
492
489
)
493
490
494
491
const onAnimationRepeat = ( ) => {
495
- if ( shouldAvoidDoubleSpin . current ) return
492
+ // we avoid spinning a second time if the user has just clicked the button
493
+ if ( backgroundRef . current ?. disabled ) return
496
494
inc ( )
497
495
}
498
496
@@ -506,10 +504,12 @@ export function Wires({ className }: { className?: string }) {
506
504
const onBackgroundClick = useMemo (
507
505
( ) =>
508
506
throttle ( ( ) => {
507
+ const button = backgroundRef . current
508
+ if ( ! button ) return
509
+ button . disabled = true
509
510
inc ( )
510
- shouldAvoidDoubleSpin . current = true
511
511
setTimeout ( ( ) => {
512
- shouldAvoidDoubleSpin . current = false
512
+ button . disabled = false
513
513
} , 750 )
514
514
} , 500 ) ,
515
515
[ ] ,
@@ -541,6 +541,7 @@ export function Wires({ className }: { className?: string }) {
541
541
< SVGDefinitions />
542
542
</ svg >
543
543
< button
544
+ ref = { backgroundRef }
544
545
tabIndex = { - 1 }
545
546
onClick = { onBackgroundClick }
546
547
aria-label = { step === 2 ? "Show query again" : "Next step" }
0 commit comments