Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/pages/base-ui/api/use-autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@
},
"getOptionProps": {
"type": {
"name": "(renderedOption: UseAutocompleteRenderedOption<Value>) => React.HTMLAttributes<HTMLLIElement> & { key: any }",
"description": "(renderedOption: UseAutocompleteRenderedOption<Value>) => React.HTMLAttributes<HTMLLIElement> & { key: any }"
"name": "(renderedOption: UseAutocompleteRenderedOption<Value>) => UseAutocompleteGetOptionPropsReturnValue",
"description": "(renderedOption: UseAutocompleteRenderedOption<Value>) => UseAutocompleteGetOptionPropsReturnValue"
},
"required": true
},
Expand Down
6 changes: 5 additions & 1 deletion packages/mui-base/src/useAutocomplete/useAutocomplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ export interface UseAutocompleteRenderedOption<Value> {
index: number;
}

export type UseAutocompleteGetOptionPropsReturnValue = React.HTMLAttributes<HTMLLIElement> & {
key: any;
Copy link
Member

@aarongarciah aarongarciah Jun 19, 2024

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?

Suggested change
key: any;
key: React.Key;

Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/298040491bdf086e6fbfe3c9eb12fbe96c90b7fc/types/react/index.d.ts#L239-L262

Copy link
Member Author

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.

};

export interface UseAutocompleteReturnValue<
Value,
Multiple extends boolean | undefined = false,
Expand Down Expand Up @@ -411,7 +415,7 @@ export interface UseAutocompleteReturnValue<
*/
getOptionProps: (
renderedOption: UseAutocompleteRenderedOption<Value>,
) => React.HTMLAttributes<HTMLLIElement> & { key: any };
) => UseAutocompleteGetOptionPropsReturnValue;
/**
* Id for the Autocomplete.
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/mui-material/src/Autocomplete/Autocomplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
createFilterOptions,
UseAutocompleteProps,
AutocompleteFreeSoloValueMapping,
UseAutocompleteGetOptionPropsReturnValue,
} from '@mui/base';
import { IconButtonProps, InternalStandardProps as StandardProps, Theme } from '@mui/material';
import { ChipProps, ChipTypeMap } from '@mui/material/Chip';
Expand Down Expand Up @@ -325,7 +326,7 @@ export interface AutocompleteProps<
* @returns {ReactNode}
*/
renderOption?: (
props: React.HTMLAttributes<HTMLLIElement>,
props: UseAutocompleteGetOptionPropsReturnValue,
option: Value,
state: AutocompleteRenderOptionState,
ownerState: AutocompleteOwnerState<Value, Multiple, DisableClearable, FreeSolo, ChipComponent>,
Expand Down