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

[Rating] Fix Rating returns NaN when using user event #45054

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

Conversation

NooBat
Copy link

@NooBat NooBat commented Jan 18, 2025

Closes #38828

@NooBat NooBat force-pushed the fix/rating-test-with-user-event branch from cdf633e to b7804d9 Compare January 18, 2025 06:26
@zannager zannager added the component: rating This is the name of the generic UI component, not the React module! label Jan 20, 2025
@zannager zannager requested a review from sai6855 January 20, 2025 16:16
Comment on lines +410 to +415
if (Number.isNaN(newHover)) {
// Workaround for test scenario using userEvent since jsdom defaults getBoundingClientRect to 0
// Fix https://github.com/mui/material-ui/issues/38828
newHover = -1;
}

Copy link
Member

@siriwatknp siriwatknp Jan 23, 2025

Choose a reason for hiding this comment

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

Does it make more sense to return if Number.isNaN(newHover) is true?

if (Number.isNaN(newHover)) {
  return;
}

Copy link
Member

Choose a reason for hiding this comment

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

Then move the setFocusVisible(false) up before the condition so it always run.

@ZeeshanTamboli ZeeshanTamboli changed the title [fix] Fix Rating returns NaN when using user event [Rating] Fix Rating returns NaN when using user event Jan 23, 2025
@mui-bot
Copy link

mui-bot commented Jan 23, 2025

Netlify deploy preview

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

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 630b67d

@ZeeshanTamboli ZeeshanTamboli added the package: material-ui Specific to @mui/material label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

[docs][Rating] Testing the component with @testing-library/user-event results in NaN
5 participants