Skip to content

Commit 8c94e2a

Browse files
craigmjacksonoliviertassinari
authored andcommitted
[Select] Hide SVG icon for native multiple select (mui#16992)
* [Select] Ensured SVG icon is not displayed for native multiple Select components * simple test
1 parent b1ed501 commit 8c94e2a

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

packages/material-ui/src/NativeSelect/NativeSelectInput.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const NativeSelectInput = React.forwardRef(function NativeSelectInput(props, ref
2525
ref={inputRef || ref}
2626
{...other}
2727
/>
28-
<IconComponent className={classes.icon} />
28+
{props.multiple ? null : <IconComponent className={classes.icon} />}
2929
</React.Fragment>
3030
);
3131
});
@@ -58,6 +58,10 @@ NativeSelectInput.propTypes = {
5858
* @deprecated
5959
*/
6060
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
61+
/**
62+
* @ignore
63+
*/
64+
multiple: PropTypes.bool,
6165
/**
6266
* Name attribute of the `select` or hidden `input` element.
6367
*/

packages/material-ui/src/Select/Select.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,30 @@ describe('<Select />', () => {
9898
});
9999
});
100100

101+
describe('SVG icon', () => {
102+
it('should not present an SVG icon when native and multiple are specified', () => {
103+
const { container } = render(
104+
<Select native multiple value={[0, 1]}>
105+
<option value={0}>Zero</option>
106+
<option value={1}>One</option>
107+
<option value={2}>Two</option>
108+
</Select>,
109+
);
110+
expect(container.querySelector('svg')).to.be.null;
111+
});
112+
113+
it('should present an SVG icon', () => {
114+
const { container } = render(
115+
<Select native value={1}>
116+
<option value={0}>Zero</option>
117+
<option value={1}>One</option>
118+
<option value={2}>Two</option>
119+
</Select>,
120+
);
121+
expect(container.querySelector('svg')).to.be.visible;
122+
});
123+
});
124+
101125
describe('accessibility', () => {
102126
it('sets aria-expanded="true" when the listbox is displayed', () => {
103127
const { getByRole } = render(<Select open value="none" />);

0 commit comments

Comments
 (0)