Skip to content

Commit

Permalink
Port work to fix issue with using refs, original work: chrisronline@8…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline authored and cjcenizal committed Sep 19, 2017
1 parent 1e4e0ae commit 710775a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ui_framework/src/components/form/field_text/field_text.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const KuiFieldText = ({
className,
icon,
isInvalid,
inputRef,
...rest,
}) => {
const classes = classNames('kuiFieldText', className, {
Expand All @@ -39,6 +40,7 @@ export const KuiFieldText = ({
placeholder={placeholder}
className={classes}
value={value}
ref={inputRef}
{...rest}
/>
</KuiValidatableControl>
Expand All @@ -53,6 +55,7 @@ KuiFieldText.propTypes = {
value: PropTypes.string,
icon: PropTypes.string,
isInvalid: PropTypes.bool,
inputRef: PropTypes.func,
};

KuiFieldText.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ export class KuiValidatableControl extends Component {

render() {
return cloneElement(this.props.children, {
ref: node => { this.control = node; },
ref: node => {
this.control = node;

// Call the original ref, if any
const { ref } = this.props.children;
if (typeof ref === 'function') {
ref(node);
}
},
});
}
}

0 comments on commit 710775a

Please sign in to comment.