Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Input): onChange callback does not pass the value of the input when using Input with children #909

Closed
josie11 opened this issue Nov 20, 2016 · 2 comments

Comments

@josie11
Copy link
Contributor

josie11 commented Nov 20, 2016

Similar to this open issue: #907

When using the Input component with children, you have to use the onChange callback with the child input tag, and no second data parameter is passed to the callback.

Steps to Reproduce

  1. Create a Input with children, you must use your own tag as per the Docs. The semantics tag will not run the onChange callback, you must pass as an option in your tag.
  2. pass the onChange option with a callback option, have the callback console.log the arguments.

Expected
The onChange callback function should receive the input value as a second parameter in the callback.

Result
The callback option does not receive the value of the input as the second parameter.

Testcase
http://codepen.io/tintin301/pen/rWyBvw

@levithomason
Copy link
Member

levithomason commented Nov 20, 2016

Thanks for the report, this is a confirmed bug. We are not passing any of the htmlInputProps to the input child.

Input.js

const htmlInputProps = _.pick(this.props, htmlInputPropNames)
if (onChange) htmlInputProps.onChange = this.handleChange

const ElementType = getElementType(Input, this.props)

if (children) {
  return <ElementType {...rest} className={classes}>{children}</ElementType>
}

We need to find the input child and spread the htmlInputProps on it. We have a findByType() util in lib for this. We simply need to find the input child and spread the props on it.

@levithomason
Copy link
Member

See #916, will merge on pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants