-
-
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
[ButtonGroup][material-ui] Renders incorrectly with conditional elements in 5.14.9 #38978
Comments
Possibly this commit 95e41fd but not confirmed |
@Thomas101 Thanks for reporting. It's a regression from #38520. We used |
Thanks! I appreciate the fast response 👍 |
There is still a problem even with that PR. If things are wrapped in a fragment, it always renders it incorrectly. Previous to 5.14.9, this was not the case. This is a problem for us because we have some items inside the button group that are memoized. This can be seen in the above example by wrapping everything in the button group in a fragment. |
@DevRockyFish Why do you want to wrap elements inside the ButtonGroup in a React Fragment? Isn't that unnecessary? Do you mean like this? The React.Fragment is not needed there. |
@ZeeshanTamboli It is not needed there, but we have some memoized toolbar buttons that are rendered conditionally, and they all get returned out of the memo as children. So since they are children we return them out using a fragment, so some of the buttons inside our button group are in the button group like in the example, and some are returned out of a useMemo and put into the button group as additional. Alternatively we could create an array of JSX and render it that way. |
@DevRockyFish Yes, creating an array of JSX allows for dynamic button rendering without the need for Fragments, which was incorrectly used within the ButtonGroup earlier. |
So fragments won't work inside of button groups anymore is the plan? Just confirming. |
Yes. |
@ZeeshanTamboli |
I checked it, but I'm uncertain about how to resolve it. The problem is that we rely on checking valid JSX elements within the button group, and the custom Button component is considered valid, which disrupts the styles. In the past, we depended on the elements in the DOM prior to version |
Ok, for now it is fine for us to revert to version UPDATE: #39488 |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://stackblitz.com/edit/stackblitz-starters-nykpki
Steps:
Starting with version
5.14.9
, the rounded corners fail to render when the last element is undefined, for example...Current behavior 😯
The rounded corners on the last element are missing...
Expected behavior 🤔
Rounded corners should be visible on the last element. This works correctly in
5.14.8
and earlierContext 🔦
Conditionally rendering elements in the ButtonGroup. Without this they need to be rendered into an array and filtered before being passed as children
Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: