Skip to content

Commit

Permalink
[Select] Fix specificity of style overrides (#25766)
Browse files Browse the repository at this point in the history
  • Loading branch information
robphoenix authored Apr 19, 2021
1 parent 88fcc1b commit 3815264
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions packages/material-ui/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import clsx from 'clsx';
import MuiError from '@material-ui/utils/macros/MuiError.macro';
import { unstable_composeClasses as composeClasses } from '@material-ui/unstyled';
import { refType, deepmerge } from '@material-ui/utils';
import { refType } from '@material-ui/utils';
import ownerDocument from '../utils/ownerDocument';
import capitalize from '../utils/capitalize';
import Menu from '../Menu/Menu';
Expand All @@ -17,20 +17,23 @@ import selectClasses, { getSelectUtilityClasses } from './selectClasses';

const overridesResolver = (props, styles) => {
const { styleProps } = props;
return deepmerge(
{
return {
[`&.${selectClasses.select}`]: {
// TODO v5: remove `root` and `selectMenu`
...styles.root,
...styles.select,
...styles.selectMenu,
...styles[styleProps.variant],
},
styles.root || {},
);
};
};

const SelectRoot = experimentalStyled(
'div',
{},
{ name: 'MuiSelect', slot: 'Root', overridesResolver },
)(nativeSelectRootStyles, {
// Win specificity over the input base
[`&.${selectClasses.selectMenu}`]: {
height: 'auto', // Resets for multiple select with chips
minHeight: '1.4375em', // Required for select\text-field height consistency
Expand All @@ -42,13 +45,11 @@ const SelectRoot = experimentalStyled(

const iconOverridesResolver = (props, styles) => {
const { styleProps } = props;
return deepmerge(
{
...(styleProps.variant && styles[`icon${capitalize(styleProps.variant)}`]),
...(styleProps.open && styles.iconOpen),
},
styles.icon || {},
);
return {
...styles.icon,
...(styleProps.variant && styles[`icon${capitalize(styleProps.variant)}`]),
...(styleProps.open && styles.iconOpen),
};
};

const SelectIcon = experimentalStyled(
Expand Down

0 comments on commit 3815264

Please sign in to comment.