-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Add support for "{label: string}" data type as a default for "options" #21992
[Autocomplete] Add support for "{label: string}" data type as a default for "options" #21992
Conversation
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.
I have added some documentation, let me know what you think about it
packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts
Outdated
Show resolved
Hide resolved
packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts
Outdated
Show resolved
Hide resolved
packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts
Outdated
Show resolved
Hide resolved
packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
Outdated
Show resolved
Hide resolved
@@ -270,7 +270,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) { | |||
fullWidth = false, | |||
getLimitTagsText = (more) => `+${more}`, | |||
getOptionDisabled, | |||
getOptionLabel = (x) => x, | |||
getOptionLabel = (x) => x.label ?? x, |
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.
getOptionLabel = (x) => x.label ?? x, | |
getOptionLabel = (option) => option.label ?? x, |
to use a descriptive name similar to useAutocomplete.
…lete and useAutocomplete
f27c25c
to
9dfab0d
Compare
Since this got quite messy I've cleaned up the commits to have only one containing all the changes plus everyone's feedback |
@DanailH It depends, on what you want to optimize for. If you need to rebase, definitely help. Otherwise, I think that keeping the commit history is better, they get squashed anyway once merged. |
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.
One question though: It seems like this doesn't add a default options type but changes it from string
to { label: string }
, no? This should be reflected in the PR title, description and label to create a proper changelog.
{label: string}
data type for options
{label: string}
data type for options
I've updated the title and the description. Just to be clear, the default options type doesn't change from |
The previous label getters were |
@DanailH Well done :) |
This PR aims to add support for
{label: string}
data type foroptions
in the Autocomplete UI component, as it was discussed in #21693I've also updated one of the examples (the
ComboBox
one to have the new options type). I can revert that if it is not needed.Fixes #21693