Skip to content

Commit

Permalink
fix #41356
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Mar 8, 2024
1 parent 0804ff7 commit d7bda2a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/mui-material/src/Select/Select.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export interface OutlinedSelectProps extends Omit<OutlinedInputProps, 'value' |
* The variant to use.
* @default 'outlined'
*/
variant: 'outlined';
variant?: 'outlined';
}

export type SelectVariants = 'outlined' | 'standard' | 'filled';
Expand Down
47 changes: 46 additions & 1 deletion packages/mui-material/src/Select/Select.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import Select, { SelectChangeEvent } from '@mui/material/Select';
import Select, { SelectChangeEvent, SelectProps } from '@mui/material/Select';
import MenuItem from '@mui/material/MenuItem';
import { createTheme } from '@mui/material/styles';

Expand Down Expand Up @@ -95,4 +95,49 @@ function genericValueTest() {
<Select variant="standard" />;
<Select variant="outlined" />;
<Select />;

const defaultProps: SelectProps<number> = {};
const outlinedProps: SelectProps<number> = {
variant: 'outlined',
};
const filledProps: SelectProps<number> = {
variant: 'filled',
};
const standardProps: SelectProps<number> = {
variant: 'standard',
};

<Select {...defaultProps} />;
<Select {...outlinedProps} />;
<Select {...filledProps} />;
<Select {...standardProps} />;
<Select<number> {...outlinedProps} />;
<Select<number> {...defaultProps} />;
<Select<number, 'standard'> {...standardProps} />;
// @ts-expect-error variant type mismatch
<Select<number> {...filledProps} />;
// @ts-expect-error variant type mismatch
<Select<number, 'outlined'> {...filledProps} />;
// @ts-expect-error variant type mismatch
<Select<number, 'standard'> {...filledProps} />;

const rawDefaultProps: SelectProps = {};
const rawOutlinedProps: SelectProps = {
variant: 'outlined',
};
const rawFilledProps: SelectProps = {
variant: 'filled',
};

<Select {...rawDefaultProps} />;
<Select {...rawOutlinedProps} />;
<Select {...rawFilledProps} />;

// @ts-expect-error hiddenLabel is not present in outlined variant
<Select {...defaultProps} hiddenLabel />;
// @ts-expect-error hiddenLabel is not present in outlined variant
<Select {...outlinedProps} hiddenLabel />;
<Select {...filledProps} hiddenLabel />;
// @ts-expect-error hiddenLabel is not present in standard variant
<Select {...standardProps} hiddenLabel />;
}

0 comments on commit d7bda2a

Please sign in to comment.