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] Component does not respect name property when generating input element id #40997

Closed
3eggwhites opened this issue Feb 8, 2024 · 10 comments · Fixed by #43829
Assignees
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

Comments

@3eggwhites
Copy link

3eggwhites commented Feb 8, 2024

Steps to reproduce

Link to live example: I have created a small project to demonstrate the issue, repository link can be found here: https://github.com/3eggwhites/mui-rating-component-issue/

Prerequisites

  • Node: v16.20.2
  • PNPM: 8.15.1

Libraries Used

  • React: 17
  • MUI: 5.15.7

Setup:

  1. git clone https://github.com/3eggwhites/mui-rating-component-issue.git
  2. cd mui-rating-component-issue
  3. pnpm install
  4. pnpm -r run build
  5. pnpm -r run preview

Steps:

  1. open http://localhost:5001/ url in Google Chrome or Safari
  2. change rating value for the Remote Rating component
  3. open browser devtool to inspect input element ids associated to the Rating component

Current behavior

input element ids are not generated using the name property given to Rating component
Changing the value of Remote Rating component affects the state of Host Rating component.

Expected behavior

input element ids should be generated using the name property given to Rating component
Changing the value of Remote Rating component should not affect the state of Host Rating component and only change the state of Remote Rating component

Context

We are trying to use Rating component in a Microfrontend project. When two microfrontends which contains the Rating component are rendered on to the same DOM, they are affecting each other's state.

On further inspection we found that the input element ids are same for the Rating components.

This issue is noticed only when using React v17, in React v18 the issue does not occur.

The name property is ignored while generating ids for the input elements of Rating component, which is not following the api documentation https://mui.com/material-ui/api/rating/#rating-prop-name

Your environment

npx @mui/envinfo
  System:
    OS: macOS 13.6.3
  Binaries:
    Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node
    npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm
    pnpm: 8.15.1 - ~/homebrew/bin/pnpm
  Browsers:
    Chrome: 121.0.6167.139
    Edge: 121.0.2277.106
    Safari: 17.2.1

Search keywords: Rating, material-ui

@3eggwhites 3eggwhites added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 8, 2024
@danilo-leal danilo-leal added package: material-ui Specific to @mui/material component: rating This is the name of the generic UI component, not the React module! labels Feb 8, 2024
@3eggwhites
Copy link
Author

3eggwhites commented Feb 19, 2024

Hello Team,
Any update on this issue?
@mj12albert @zannager

@ZeeshanTamboli
Copy link
Member

@3eggwhites I am getting the following error when running pnpm install:

pnpm install
Scope: all 3 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +180
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ERR_PNPM_FETCH_404  GET https://registry.npmjs.org/com.db.gtb.cbps.the-design-system/-/com.db.gtb.cbps.the-design-system
-3.3.1.tgz: Not Found - 404

No authorization header was set for the request.
Progress: resolved 180, reused 72, downloaded 2, added 11

@ZeeshanTamboli ZeeshanTamboli added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 5, 2024
@3eggwhites
Copy link
Author

3eggwhites commented Mar 5, 2024

@3eggwhites I am getting the following error when running pnpm install:

pnpm install
Scope: all 3 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +180
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ERR_PNPM_FETCH_404  GET https://registry.npmjs.org/com.db.gtb.cbps.the-design-system/-/com.db.gtb.cbps.the-design-system
-3.3.1.tgz: Not Found - 404

No authorization header was set for the request.
Progress: resolved 180, reused 72, downloaded 2, added 11

Hello @ZeeshanTamboli, my bad I have removed the bad package which was causing issue during install. Kindly clone the project again to avoid any further issues

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Mar 5, 2024
@ZeeshanTamboli
Copy link
Member

Not sure what could be the solution here. It's incorrect that one rating component should affect the other. I'll mark it as a bug.

@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 6, 2024
@3eggwhites
Copy link
Author

Hi Team, any update on this?

@ZeeshanTamboli
Copy link
Member

@3eggwhites Would you like to give it a try?

@yash49
Copy link
Contributor

yash49 commented Sep 20, 2024

Hi @mj12albert @ZeeshanTamboli
I would like to give it a try. Do let me know if I can work on this issue or not.

@yash49
Copy link
Contributor

yash49 commented Sep 20, 2024

reference - https://mui.com/material-ui/api/rating/#rating-prop-name
image

@mj12albert @ZeeshanTamboli the Rating component does not use name for generated ids
#43829 is my proposal - using name as prefix for generated ids fixes problem described by @3eggwhites

let me know your thoughts

@ZeeshanTamboli
Copy link
Member

@yash49 Reviewed you PR. Thanks.

Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

We value your feedback @3eggwhites! How was your experience with our support team?
We'd love to hear your thoughts in this brief Support Satisfaction survey. Your insights help us improve!

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 a pull request may close this issue.

5 participants