1- import React from 'react' ;
1+ import React , { useCallback } 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.nativeRef] Action to perform to obtain the native 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
@@ -46,6 +47,7 @@ export default function InputField({
4647 maxLength,
4748 min,
4849 name,
50+ nativeRef,
4951 onChange,
5052 pattern,
5153 placeholder,
@@ -74,6 +76,11 @@ export default function InputField({
7476 }
7577 } ;
7678
79+ const ref2 = useCallback ( ( node ) => {
80+ inputRef ( node ) ;
81+ nativeRef ( node ) ;
82+ } , [ nativeRef ] ) ;
83+
7784 useAutoFocus ( inputRef , autoFocus ) ;
7885
7986 return (
@@ -105,7 +112,7 @@ export default function InputField({
105112 onKeyDown = { onKeyDown }
106113 pattern = { pattern }
107114 placeholder = { placeholder }
108- ref = { inputRef }
115+ ref = { ref2 }
109116 required = { required }
110117 tabIndex = { tabIndex }
111118 type = { type }
@@ -138,6 +145,7 @@ InputField.propTypes = {
138145 maxLength : PropTypes . number ,
139146 min : PropTypes . number ,
140147 name : PropTypes . string ,
148+ nativeRef : PropTypes . func ,
141149 onChange : PropTypes . func ,
142150 pattern : PropTypes . string ,
143151 placeholder : PropTypes . string ,
@@ -168,6 +176,7 @@ InputField.defaultProps = {
168176 maxLength : undefined ,
169177 min : undefined ,
170178 name : undefined ,
179+ nativeRef : ( ) => { } ,
171180 onChange : undefined ,
172181 pattern : undefined ,
173182 placeholder : undefined ,
0 commit comments