Skip to content
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

[material-ui][Rating] Use Rating name as prefix of input element ids #43829

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yash49
Copy link
Contributor

@yash49 yash49 commented Sep 20, 2024

fixes #40997

@mui-bot
Copy link

mui-bot commented Sep 20, 2024

Netlify deploy preview

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

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 8c79c53

@yash49 yash49 changed the title [mui-material][Rating] Use Rating name as prefix of generated id-s [mui-material][Rating] Use Rating name as prefix of input element ids Sep 20, 2024
@ZeeshanTamboli ZeeshanTamboli added package: material-ui Specific to @mui/material component: rating This is the name of the generic UI component, not the React module! bug 🐛 Something doesn't work labels Sep 27, 2024
@ZeeshanTamboli ZeeshanTamboli changed the title [mui-material][Rating] Use Rating name as prefix of input element ids [material-ui][Rating] Use Rating name as prefix of input element ids Sep 27, 2024
@ZeeshanTamboli ZeeshanTamboli marked this pull request as ready for review September 27, 2024 10:54
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.

Looks good. We also need to add unit test for it.

@@ -242,7 +242,8 @@ function RatingItem(props) {
const isFocused = itemValue <= focus;
const isChecked = itemValue === ratingValueRounded;

const id = useId();
const id = `${name ? `${name}-` : ''}${useId()}`;
Copy link
Member

Choose a reason for hiding this comment

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

A simpler version:

Suggested change
const id = `${name ? `${name}-` : ''}${useId()}`;
const id = name ? `${name}-${useId()}` : useId();

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: rating This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[material-ui][Rating] Component does not respect name property when generating input element id
3 participants