[Select] fix server-side-rendering value flickering on select input #3784
+182
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a flickering issue when using react-select with server-side rendering (Next.js, TanStack Start).
The root cause was that prerendering was not working correctly in these environments, causing the selected value to appear only after the JavaScript loaded, which led to CLS issues.
Gravacao.de.Tela.2025-12-31.as.00.10.13.mov
Gravacao.de.Tela.2025-12-31.as.00.09.05.mov
Solution
To support SSR, prerendering was added to the Select components, mainly for the Select Options. Components that previously did not support SSR were replaced with div elements so that prerendering would work correctly. With prerendering in place, we now iterate through the Select component’s children tree to find the selected item and use it as the value for the correct prerendered output.
Fixes #3431