Skip to content

Commit

Permalink
Merge pull request #1647 from nylon22/master
Browse files Browse the repository at this point in the history
fix(CustomInput): remove type prop from input node when type is select #1617
  • Loading branch information
GoPro16 committed Oct 4, 2019
2 parents 7b3f710 + 3e4c23f commit ceb482b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/CustomInput.js
Expand Up @@ -54,7 +54,8 @@ function CustomInput(props) {
const labelHtmlFor = htmlFor || attributes.id;

if (type === 'select') {
return <select {...attributes} ref={innerRef} className={classNames(validationClassNames, customClass)}>{children}</select>;
const { type, ...rest } = attributes;
return <select {...rest} ref={innerRef} className={classNames(validationClassNames, customClass)}>{children}</select>;
}

if (type === 'file') {
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/CustomInput.spec.js
Expand Up @@ -202,6 +202,11 @@ describe('Custom Inputs', () => {
expect(select.find('select').prop('data-testprop')).toBe('yo');
});

it('should remove type prop from the input node', () => {
const select = mount(<CustomInput type="select" />);
expect(select.find('select').prop('type')).toBeUndefined();
});

it('should reference innerRef to the select node', () => {
const ref = React.createRef();
mount(<CustomInput type="select" innerRef={ref} />);
Expand Down

0 comments on commit ceb482b

Please sign in to comment.