-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[base-ui][Select] Fix Select button layout shift, add placeholder prop #38796
[base-ui][Select] Fix Select button layout shift, add placeholder prop #38796
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 |
@@ -20,7 +20,7 @@ describe('<Select />', () => { | |||
const { render } = createRenderer(); | |||
|
|||
const componentToTest = ( | |||
<Select defaultListboxOpen slotProps={{ popper: { disablePortal: true } }}> | |||
<Select defaultListboxOpen defaultValue={1} slotProps={{ popper: { disablePortal: true } }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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
renderValue
function 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