[select] Fix mouse selection in StrictMode dev#4897
Conversation
Re-sync CompositeList elementsRef from sortedMap after StrictMode cleanup wipes refs without re-running item ref callbacks, which broke list navigation and mouse selection in Select.
Bundle size
PerformanceTotal duration: 1,510.19 ms 🔺+261.18 ms(+20.9%) | Renders: 50 (+0) | Paint: 2,297.37 ms 🔺+401.98 ms(+21.2%)
…and 2 more (+5 within noise) — 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. |
Use React.Fragment in CompositeList test and limit StrictMode Select regression test to jsdom where the popup opens reliably.
commit: |
|
@uixmat thanks for the fix — mouse selection without highlight was already fixed in #4699, so the tests should prove that Note this also adds an extra O(n) scan just to fix a rare dev mode problem, ideally it would be cheaper. |
No problem, go-ahead and close the PR if you like, i'll hunt down some other issues! |
Summary
CompositeListelementsReffromsortedMapon each layout effect run so list navigation can resolve live DOM nodes after StrictMode cleanup wipes refs without re-running item ref callbacksSelect(and other composite list consumers) in React StrictMode dev environments such as Next.js devFixes #4698
Test plan
pnpm test:jsdom CompositeList --no-watchpnpm test:jsdom SelectRoot --no-watch