[base-ui][Select] Fix Select button layout shift, add placeholder prop#38796
[base-ui][Select] Fix Select button layout shift, add placeholder prop#38796mj12albert merged 9 commits intomui:masterfrom
Conversation
Netlify deploy previewhttps://deploy-preview-38796--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
|
We can include the placeholder and ZWS in the Select component itself, not just the demos. |
a070f57 to
61216d4
Compare
775926c2b424cfcaeda1be14ef073924cca7e659
9554a5fbe92bf4de14c09ed7b2f25503dea3e8cd
61216d4 to
3effe97
Compare
|
@michaldudak I've added the I don't think it needs to be added to the hook, as |
|
|
||
| const componentToTest = ( | ||
| <Select defaultListboxOpen slotProps={{ popper: { disablePortal: true } }}> | ||
| <Select defaultListboxOpen defaultValue={1} slotProps={{ popper: { disablePortal: true } }}> |
There was a problem hiding this comment.
This is so that the ZWS is not rendered, or else className="notranslate" will cause the "test disabling class generation" part of describeConformanceUnstyled to fail
Nice, Next.js users will be happy 👌 |
Fixes 1 of 3 in mui/base-ui#37, solving this hydration layout shift:
Screen.Recording.2023-09-14.at.23.32.21.mov
This PR adds updates the default
renderValuefunction to fall back to a zero-width space that prevents layout shift in SSR or when the value is empty.Preview link (disable JS to try) https://deploy-preview-38796--material-ui.netlify.app/base-ui/react-select/#introduction
New demo: https://deploy-preview-38796--material-ui.netlify.app/base-ui/react-select/#option-appearance