Skip to content

Commit

Permalink
[material-ui][Autocomplete] Add typescript test for PaperComponent \w…
Browse files Browse the repository at this point in the history
… extended props
  • Loading branch information
Ektoras Tavoularis committed Apr 15, 2024
1 parent f969326 commit 3501b67
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/mui-material/src/Autocomplete/Autocomplete.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Autocomplete, {
} from '@mui/material/Autocomplete';
import TextField from '@mui/material/TextField';
import { ChipTypeMap } from '@mui/material/Chip';
import Paper, { type PaperProps } from '@mui/material/Paper';

interface MyAutocompleteProps<
T,
Expand Down Expand Up @@ -171,3 +172,33 @@ function CustomListboxRef() {
>(e);
}}
/>;

type PaperComponentProps = { title?: string };
declare module '@mui/material/Paper' {
export interface PaperBaseProps extends PaperComponentProps {}
}

function PaperComponent({ title, children, ...props }: PaperProps) {
return (
<Paper {...props}>
{title}
{children}
</Paper>
);
}

function AutocompleteCustomPaper() {
return (
<Autocomplete
options={['one', 'two', 'three']}
renderInput={(params) => <TextField {...params} />}
PaperComponent={PaperComponent}
componentsProps={{
paper: {
title: 'Title',
variant: 'outlined',
},
}}
/>
);
}

0 comments on commit 3501b67

Please sign in to comment.