Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 0 additions & 6 deletions docs/pages/material-ui/api/native-select.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@
"description": "Styles applied to the icon component if `variant=\"filled\"`.",
"isGlobal": false
},
{
"key": "iconOpen",
"className": "MuiNativeSelect-iconOpen",
"description": "Styles applied to the icon component if the popup is open.",
"isGlobal": false
},
{
"key": "iconOutlined",
"className": "MuiNativeSelect-iconOutlined",
Expand Down
5 changes: 0 additions & 5 deletions docs/translations/api-docs/native-select/native-select.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
"nodeName": "the icon component",
"conditions": "<code>variant=\"filled\"</code>"
},
"iconOpen": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the icon component",
"conditions": "the popup is open"
},
"iconOutlined": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the icon component",
Expand Down
16 changes: 3 additions & 13 deletions packages/mui-material/src/NativeSelect/NativeSelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import rootShouldForwardProp from '../styles/rootShouldForwardProp';
import inputAdornmentClasses from '../InputAdornment/inputAdornmentClasses';

const useUtilityClasses = (ownerState) => {
const { classes, variant, disabled, multiple, open, error } = ownerState;
const { classes, variant, disabled, multiple, error } = ownerState;

const slots = {
select: ['select', variant, disabled && 'disabled', multiple && 'multiple', error && 'error'],
icon: ['icon', `icon${capitalize(variant)}`, open && 'iconOpen', disabled && 'disabled'],
icon: ['icon', `icon${capitalize(variant)}`, disabled && 'disabled'],
};

return composeClasses(slots, getNativeSelectUtilityClasses, classes);
Expand Down Expand Up @@ -146,12 +146,6 @@ export const StyledSelectIcon = styled('svg', {
color: (theme.vars || theme).palette.action.disabled,
},
variants: [
{
props: ({ ownerState }) => ownerState.open,
style: {
transform: 'rotate(180deg)',
},
},
{
props: {
variant: 'filled',
Expand All @@ -176,11 +170,7 @@ const NativeSelectIcon = styled(StyledSelectIcon, {
slot: 'Icon',
overridesResolver: (props, styles) => {
const { ownerState } = props;
return [
styles.icon,
ownerState.variant && styles[`icon${capitalize(ownerState.variant)}`],
ownerState.open && styles.iconOpen,
];
return [styles.icon, ownerState.variant && styles[`icon${capitalize(ownerState.variant)}`]];
},
})({});

Expand Down
3 changes: 0 additions & 3 deletions packages/mui-material/src/NativeSelect/nativeSelectClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export interface NativeSelectClasses {
disabled: string;
/** Styles applied to the icon component. */
icon: string;
/** Styles applied to the icon component if the popup is open. */
iconOpen: string;
/** Styles applied to the icon component if `variant="filled"`. */
iconFilled: string;
/** Styles applied to the icon component if `variant="outlined"`. */
Expand Down Expand Up @@ -47,7 +45,6 @@ const nativeSelectClasses: NativeSelectClasses = generateUtilityClasses('MuiNati
'standard',
'disabled',
'icon',
'iconOpen',
'iconFilled',
'iconOutlined',
'iconStandard',
Expand Down
7 changes: 7 additions & 0 deletions packages/mui-material/src/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2774,6 +2774,13 @@ describe('<Select />', () => {
});
});

it('should rotate the icon when open', () => {
const { container } = render(<Select open value="" />);
const icon = container.querySelector(`.${classes.icon}`);
expect(icon).to.have.class(classes.iconOpen);
expect(icon).not.toHaveComputedStyle({ transform: 'none' });
});

describe('prop: input', () => {
it('merges `ref` of `Select` and `input`', () => {
const Input = React.forwardRef(function Input(props, ref) {
Expand Down
11 changes: 10 additions & 1 deletion packages/mui-material/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,16 @@ const SelectIcon = styled(StyledSelectIcon, {
const { ownerState } = props;
return [styles.icon, ownerState.open && styles.iconOpen];
},
})({});
})({
variants: [
{
props: ({ ownerState }) => ownerState.open,
style: {
transform: 'rotate(180deg)',
},
},
],
});

const SelectNativeInput = styled('input', {
shouldForwardProp: (prop) => slotShouldForwardProp(prop) && prop !== 'classes',
Expand Down
Loading