Skip to content

Commit

Permalink
[Select] Simplify handleChange in SelectInput (#37040)
Browse files Browse the repository at this point in the history
Co-authored-by: ZeeshanTamboli <zeeshan.tamboli@gmail.com>
  • Loading branch information
ulrichstark and ZeeshanTamboli committed May 4, 2023
1 parent 7c385b4 commit 3fe6e91
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/mui-material/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,12 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {

// Support autofill.
const handleChange = (event) => {
const index = childrenArray.map((child) => child.props.value).indexOf(event.target.value);
const child = childrenArray.find((childItem) => childItem.props.value === event.target.value);

if (index === -1) {
if (child === undefined) {
return;
}

const child = childrenArray[index];
setValueState(child.props.value);

if (onChange) {
Expand Down

0 comments on commit 3fe6e91

Please sign in to comment.