Skip to content

Commit 2810bad

Browse files
Input ref fix (bl00mber#187) (bl00mber#449)
1 parent 9deb73a commit 2810bad

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,12 +950,19 @@ class PhoneInput extends React.Component {
950950
onBlur={this.handleInputBlur}
951951
onCopy={this.handleInputCopy}
952952
value={formattedNumber}
953-
ref={el => this.numberInputRef = el}
954953
onKeyDown={this.handleInputKeyDown}
955954
placeholder={this.props.placeholder}
956955
disabled={this.props.disabled}
957956
type='tel'
958957
{...this.props.inputProps}
958+
ref={el => {
959+
this.numberInputRef = el;
960+
if (typeof this.props.inputProps.ref === 'function') {
961+
this.props.inputProps.ref(el);
962+
} else if (typeof this.props.inputProps.ref === 'object') {
963+
this.props.inputProps.ref.current = el;
964+
}
965+
}}
959966
/>
960967

961968
<div

0 commit comments

Comments
 (0)