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

[Autocomplete] extend renderOption prop type to allow key and ref #30208

Closed
wants to merge 1 commit into from
Closed

[Autocomplete] extend renderOption prop type to allow key and ref #30208

wants to merge 1 commit into from

Conversation

PascalLuginbuehl
Copy link
Contributor

I would like to be able to override the key property for renderOption. Like so

renderOption={(props, option, state) => renderOption({ ...props, key: option[optionValueField] }, option, state)}

Unfortunatyle this throws the following error
Object literal may only specify known properties, and 'key' does not exist in type 'HTMLAttributes<HTMLLIElement>'.

@mui-pr-bot
Copy link

mui-pr-bot commented Dec 14, 2021

No bundle size changes

Generated by 🚫 dangerJS against 6dc8367

@PascalLuginbuehl
Copy link
Contributor Author

This merge request fails because React.DetailedHTMLProps still uses LegacyRef which enables the ref to be a string.

OverridableComponent no longer supports LegacyRef, only the new Ref type, Thats why the following error occurs

Type 'LegacyRef<HTMLLIElement> | undefined' is not assignable to type 'Ref<unknown> | undefined'.
          Type 'string' is not assignable to type 'Ref<unknown> | undefined'.

I would appreciate some help on this matter.

@danilo-leal danilo-leal added the component: autocomplete This is the name of the generic UI component, not the React module! label Feb 1, 2022
@siriwatknp
Copy link
Member

👋 The migration PR has been merged.

Please follow these steps to make sure that the contents are all updated. (Sorry for the inconvenience)

  1. pull latest master from upstream to your branch
  2. if your PR has changes on the *.md or demo files, you are likely to encounter conflict because all of them have been moved to the new folder.
    2.1 revert the change on those markdown files you did
    2.2 pull latest master from upstream (you should not see conflict)
    2.3 make the changes again at docs/data/material/*
  3. run yarn docs:api
    • you might see the changes in docs/pages/material/api/* if your PR touches some of the components
    • it is okay if there is no changes

If you are struggle with the steps above, feel free to tag @siriwatknp

@mnajdova
Copy link
Member

@PascalLuginbuehl please open an issue and we can take a look and provide fix there. Looks like the renderOption you are talking about is defined in your codebase. When creating an issue make sure to share codesandbox with the whole code, so that it's clear what's the problem.

@mnajdova mnajdova closed this Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete 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.

5 participants