-
-
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
[material-ui][Autocomplete] Fix renderOption props type #42689
Conversation
Netlify deploy previewhttps://deploy-preview-42689--material-ui.netlify.app/ Bundle size report |
@aarongarciah I've added the "React 19 support" label so we can add it to all PRs related to React 19, in case we need to backport it from v6 (next) to v5 (master). I also added the needs cherry-picking label as this is an issue currently affecting users: #39833 (comment) |
Also, I didn't find any other similar type bugs in other components 👍🏼 |
@@ -361,6 +361,10 @@ export interface UseAutocompleteRenderedOption<Value> { | |||
index: number; | |||
} | |||
|
|||
export type UseAutocompleteGetOptionPropsReturnValue = React.HTMLAttributes<HTMLLIElement> & { | |||
key: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the type coming from @types/react
?
key: any; | |
key: React.Key; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, yes, but I would keep any as that's the type declared in Base's getOptionProps and we don't want to update that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Left a couple of inline comments for your consideration.
Closes #39833
Fixes second bug described in #39833 (comment). The first bug was fixed in #42099.
Use the correct type for
renderOptions
'sprops
callback argument. The type comes from UseAutocompleteReturnValue.Before: https://codesandbox.io/p/sandbox/39833-render-option-type-next-vd4jpp?file=%2Fsrc%2FDemo.tsx
After: https://codesandbox.io/p/devbox/f27pj7?file=%2Fsrc%2FDemo.tsx%3A7%2C18