Skip to content

Commit

Permalink
[material-ui][Select] Add missing root class (#44928)
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 authored Jan 3, 2025
1 parent e7a9490 commit 7968611
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/mui-material/src/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import deepmerge from '@mui/utils/deepmerge';
import composeClasses from '@mui/utils/composeClasses';
import getReactElementRef from '@mui/utils/getReactElementRef';
import SelectInput from './SelectInput';
import formControlState from '../FormControl/formControlState';
Expand All @@ -16,11 +17,18 @@ import { useDefaultProps } from '../DefaultPropsProvider';
import useForkRef from '../utils/useForkRef';
import { styled } from '../zero-styled';
import rootShouldForwardProp from '../styles/rootShouldForwardProp';
import { getSelectUtilityClasses } from './selectClasses';

const useUtilityClasses = (ownerState) => {
const { classes } = ownerState;

return classes;
const slots = {
root: ['root'],
};

const composedClasses = composeClasses(slots, getSelectUtilityClasses, classes);

return { ...classes, ...composedClasses };
};

const styledRootConfig = {
Expand Down
15 changes: 15 additions & 0 deletions packages/mui-material/src/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,21 @@ describe('<Select />', () => {
expect(selectRef).to.deep.equal({ current: { refToInput: true } });
});

it('should have root class', () => {
const { container } = render(
<Select value={10}>
<MenuItem value="">
<em>None</em>
</MenuItem>
<MenuItem value={10}>Ten</MenuItem>
<MenuItem value={20}>Twenty</MenuItem>
<MenuItem value={30}>Thirty</MenuItem>
</Select>,
);

expect(container.querySelector(`.${classes.root}`)).not.to.equal(null);
});

it('should merge the class names', () => {
const { getByTestId } = render(
<Select
Expand Down

0 comments on commit 7968611

Please sign in to comment.