Skip to content

Commit

Permalink
fix(Tag): inside ref
Browse files Browse the repository at this point in the history
  • Loading branch information
zouxuoz committed Mar 26, 2019
1 parent d007567 commit 226617d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/common/Tag/Tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type TagProps = {|
onKeyUp?: (event?: SyntheticKeyboardEvent) => void,
onKeyDown?: (event?: SyntheticKeyboardEvent) => void,
onSubmit?: () => void,
onScroll?: () => void,
options?: Array<Object>,
placeholder?: string,
rows?: number | string,
Expand Down Expand Up @@ -62,6 +63,7 @@ const COLLECTED_PROPS = [
'onKeyUp',
'onKeyDown',
'onSubmit',
'onScroll',
'options',
'placeholder',
'rows',
Expand Down Expand Up @@ -94,6 +96,7 @@ const HTML_TAGS = [
'label',
'nav',
'img',
'pre',
];

const collectProps = (props) => pickBy(props, (value, name) => COLLECTED_PROPS.indexOf(name) !== -1 || /^data-/.test(name));
Expand All @@ -108,7 +111,11 @@ class Tag extends PureComponent<TagProps> {

const collectedProps = HTML_TAGS.indexOf(TagComponent) === -1 ? props : collectProps(props);

return <TagComponent { ...collectedProps } ref={ props.insideRef } />;
if (HTML_TAGS.indexOf(TagComponent) !== -1) {
collectedProps.ref = props.insideRef;
}

return <TagComponent { ...collectedProps } />;
}
}

Expand Down

0 comments on commit 226617d

Please sign in to comment.