1- import React from 'react' ;
1+ import React , { useEffect } from 'react' ;
22import PropTypes from 'prop-types' ;
33import classNames from 'classnames' ;
44import webexComponentClasses from '../../helpers' ;
@@ -22,6 +22,7 @@ import Label from '../../inputs/Label/Label';
2222 * @param {number } [props.maxLength] Maximum number of characters allowed
2323 * @param {number } [props.min] Minimum value for the input element
2424 * @param {string } [props.name] Input name
25+ * @param {Function } [props.onBrowserControlRef] Action to perform to take the input ref
2526 * @param {Function } [props.onChange] Action to perform on input change
2627 * @param {string } [props.pattern] Specifies a regular expression that the element's value is checked against
2728 * @param {string } [props.placeholder] Input placeholder
@@ -47,6 +48,7 @@ export default function InputField({
4748 min,
4849 name,
4950 onChange,
51+ onBrowserControlRef,
5052 pattern,
5153 placeholder,
5254 required,
@@ -63,7 +65,9 @@ export default function InputField({
6365 'has-right-controls' : rightControls ,
6466 } ) ;
6567 const inputRef = useRef ( ) ;
66- const handleChange = ( event ) => onChange ( event . target . value ) ;
68+ const handleChange = ( event ) => {
69+ onChange ( event . target . value , event . target ) ;
70+ } ;
6771 const id = domId || uniqueId ( ) ;
6872
6973 const onKeyDown = ( event ) => {
@@ -76,6 +80,10 @@ export default function InputField({
7680
7781 useAutoFocus ( inputRef , autoFocus ) ;
7882
83+ useEffect ( ( ) => {
84+ onBrowserControlRef ( inputRef . current ) ;
85+ } , [ inputRef , onBrowserControlRef ] ) ;
86+
7987 return (
8088 < Label
8189 className = { cssClasses }
@@ -139,6 +147,7 @@ InputField.propTypes = {
139147 min : PropTypes . number ,
140148 name : PropTypes . string ,
141149 onChange : PropTypes . func ,
150+ onBrowserControlRef : PropTypes . func ,
142151 pattern : PropTypes . string ,
143152 placeholder : PropTypes . string ,
144153 required : PropTypes . bool ,
@@ -169,6 +178,7 @@ InputField.defaultProps = {
169178 min : undefined ,
170179 name : undefined ,
171180 onChange : undefined ,
181+ onBrowserControlRef : ( ) => { } ,
172182 pattern : undefined ,
173183 placeholder : undefined ,
174184 required : false ,
0 commit comments