-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Forward props to renderTags() #32637
Conversation
To be able to access e.g. getOptionLabel() inside renderTags()
You can define the type of export type AutocompleteOwnerState<
T,
Multiple extends boolean | undefined,
DisableClearable extends boolean | undefined,
FreeSolo extends boolean | undefined,
ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent'],
> = AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent> & {
disablePortal: boolean;
focused: boolean;
fullWidth: boolean;
hasClearIcon: boolean;
hasPopupIcon: boolean;
inputFocued: boolean;
popupOpen: boolean;
size: OverridableStringUnion<'small' | 'medium', AutocompletePropsSizeOverrides>;
}; then pass |
* @returns {ReactNode} | ||
*/ | ||
renderTags?: ( | ||
value: T[], | ||
getTagProps: AutocompleteRenderGetTagProps, | ||
autocompleteProps: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, | ||
state: AutocompleteOwnerState<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, |
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.
Call it ownerState
please, as this name is used across the codebase and it'll be clear what state we mention.
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.
Done 👍
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.
Thanks for your work on this! I updated the code formatting (ran yarn prettier
) and synced API docs with the changes you made (yarn docs:api
). It's good to go!
In #32548 I think that we could have closed it with advising to create a new wrapper component because the use case sounds quite advanced (and for future similar cases). Now, providing the |
To make it even more consistent with other components, I would propose replacing |
To be able to access e.g. getOptionLabel() inside renderTags()
Opportunity surfaced in #32548