Skip to content

[SnackbarContent] Fix square prop not working #46196

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

0210shivam
Copy link
Contributor

@0210shivam 0210shivam commented May 23, 2025

Summary

This PR fixes an issue where the square prop on <SnackbarContent /> was not working as expected. Previously, the SnackbarContentRoot component always applied a border radius, overriding the default behavior of the underlying <Paper /> component even when square was set to true.

What’s Changed

  • Removed the hardcoded borderRadius from SnackbarContentRoot to allow the square prop to behave correctly via the underlying <Paper />.
  • Added test cases to verify that the MuiPaper-rounded class is:
    • not applied when square={true}
    • applied when square is not provided (default behavior)

Test Coverage

Added tests to ensure:

  • The square prop disables the MuiPaper-rounded class.
  • The default behavior (when square is not passed) applies the MuiPaper-rounded class.

Related Issue

Fixes #46191


@mui-bot
Copy link

mui-bot commented May 23, 2025

Netlify deploy preview

https://deploy-preview-46196--material-ui.netlify.app/

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 7e3fcfd

@0210shivam
Copy link
Contributor Author

Hey @ZeeshanTamboli , I have fix the prop issue. Could you please review the PR and let me know if there’s anything else needed? Thanks!

@astjohnpaycor
Copy link

astjohnpaycor commented May 23, 2025

@0210shivam Thank you for your prompt attention, but I believe the proper change would be to remove that hard-coded border-radius completely. The component already is inheriting the proper border-radius from the Paper styles, and already adjusts it based on whether square is true or not. The issue is that the original Paper styling is getting overridden by the hard-coded border-radius in this component.

You can see the same fix was made to the Alert component at one point: https://github.com/mui/material-ui/pull/30027/files

@0210shivam 0210shivam force-pushed the fix/snackbarcontent-square-prop-46191 branch from 215a17b to 0c62fa1 Compare May 23, 2025 16:58
@0210shivam
Copy link
Contributor Author

@astjohnpaycor Thanks for the feedback! I’ve made the changes and removed the hard-coded border-radius. Please let me know if there’s anything else to address.

@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work component: snackbar This is the name of the generic UI component, not the React module! labels May 24, 2025
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0210shivam The logic looks good. Could you please add a test case?

@0210shivam
Copy link
Contributor Author

The logic looks good. Could you please add a test case?

Sure, I’ll add a test case and update the code shortly. Thanks for reviewing.

@ZeeshanTamboli ZeeshanTamboli changed the title [SnackbarContent] Add prop to support non-rounded corners [SnackbarContent] Fix square prop not working May 24, 2025
@0210shivam 0210shivam force-pushed the fix/snackbarcontent-square-prop-46191 branch from 3358ac7 to 7e3fcfd Compare May 24, 2025 10:23
@0210shivam
Copy link
Contributor Author

@ZeeshanTamboli I’ve added the test case. Please take another look when you get a chance. Let me know if anything else is needed. Thanks again for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: snackbar This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SnackbarContent] Blocks use of the square property
4 participants