Skip to content

Commit

Permalink
fix(TextField): Spread ev on MobileSelect item click
Browse files Browse the repository at this point in the history
  • Loading branch information
JF-Cozy committed May 14, 2024
1 parent 9b9a5ed commit 49a71b0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions react/TextField/MobileSelect.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { forwardRef, useEffect, useState } from 'react'
import merge from 'lodash/merge'
import MuiTextField from '@material-ui/core/TextField'
import PropTypes from 'prop-types'

Expand Down Expand Up @@ -30,10 +31,8 @@ const MobileSelect = forwardRef(
onClick?.()
}

const handleItemClick = ({ value, children, onClick }) => {
if (onClick) {
return onClick()
}
const handleItemClick = ({ value, children, onClick }) => ev => {
onClick?.(merge({}, ev, { target: { value } }))
setState({ label: children, value })
onChange?.({ target: { value } })
}
Expand Down Expand Up @@ -89,7 +88,7 @@ const MobileSelect = forwardRef(
{...child.props}
size="small"
autoFocus={child.props.value === value}
onClick={() => handleItemClick(child.props)}
onClick={handleItemClick(child.props)}
>
<ListItemIcon>
<Radio
Expand Down

0 comments on commit 49a71b0

Please sign in to comment.