Skip to content

Commit

Permalink
fix: forward Button “ref” property
Browse files Browse the repository at this point in the history
  • Loading branch information
FezVrasta committed Jun 5, 2019
1 parent 9980128 commit 00d30e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react-core/src/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const Button = styled(
}

return (
<Tag {...specificProps} {...props}>
<Tag {...specificProps} {...props} ref={ref}>
{React.Children.map(children, node =>
['string', 'number'].includes(typeof node) ? (
<span>{node}</span>
Expand Down
6 changes: 6 additions & 0 deletions packages/react-core/src/Button/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ it('renders a Button with type=submit', () => {
expect(wrapper.find('button').props().type).toBe('submit');
});

it('forwards ref properly', () => {
const ref = React.createRef();
mount(<Button ref={ref}>Foobar</Button>);
expect(ref.current).toBeDefined();
});

// it('renders properly with isGroupChild property', () => {
// const wrapper = mount(<Button isGroupChild />);
// expect(wrapper).toMatchSnapshot();
Expand Down

0 comments on commit 00d30e9

Please sign in to comment.