Repository navigation
Conversation
… has overwritten rafId
commit: |
Bundle size
PerformanceTotal duration: 1,384.52 ms 🔺+124.48 ms(+9.9%) | Renders: 53 (+0) | Paint: 2,120.02 ms 🔺+178.69 ms(+9.2%)
…and 7 more — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Do you have a regression test for the Combobox-in-Dialog repro? I can see a bug with |
|
@atomiks Hmm, yeah fair - I think maybe the scenario I hit is actually the component unmounting while a RAF from So maybe the correct thing would be to cancel the pending RAF in |
|
OK I was actually able to put together a minimal repro here: https://github.com/stefee/base-ui-4721-repro Hope this helps! |
|
Yeah the In a real app, there's no practical bug because user interaction doesn't happen before that rAF fires (1 frame ~5-20ms), so it only shows up in a test or automated interactions The root cause:
|
|
I think this makes sense @atomiks - what do you think of something like this: stefee@133ac72 ? |
|
Yes that looks like it'd work, if all tests pass |

The cleanup function returned by
enqueueFocusonly cancels the queued RAF ifrafIdstill equalscurrentRafId:When a second call to
enqueueFocushappens after the first (e.g. a nested or concurrent popup interaction),rafIdgets overwritten. The first call's cleanup no longer matches, so its RAF is never cancelled on unmount and fires as a ghost after the component is gone.Moving the
cancelAnimationFrameoutside the guard fixes this — it's always safe to cancel a specific RAF id, even if it has already fired or been cancelled by another call.Fixes a scenario where a
Comboboxinside aDialogleaves a pending RAF after unmount that fires during a subsequent render and steals focus, preventing the popup from opening.