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): add handling of input's ref #1581

Merged
merged 2 commits into from
Apr 16, 2017
Merged

fix(Input): add handling of input's ref #1581

merged 2 commits into from
Apr 16, 2017

Conversation

layershifter
Copy link
Member

Fixes #1536.

return createHTMLInput(child, {
defaultProps: htmlInputProps,
overrideProps: this.handleInputOverrides,
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use factory instead of cloneElement

@codecov-io
Copy link

codecov-io commented Apr 13, 2017

Codecov Report

Merging #1581 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1581      +/-   ##
==========================================
+ Coverage   99.74%   99.74%   +<.01%     
==========================================
  Files         141      141              
  Lines        2381     2384       +3     
==========================================
+ Hits         2375     2378       +3     
  Misses          6        6
Impacted Files Coverage Δ
src/elements/Input/Input.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 68b08a6...eb7badc. Read the comment docs.

const ref = sandbox.spy()
const wrapper = mount(<Input><input ref={ref} /></Input>)

// ref.should.have.been.calledOnce()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@levithomason I can't get this test working, can you take a look?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refs are not passed through props. React makes them undefined. We'll have to accept the ref on a different prop name, or, update factories to include refs in the overrides. We should probably use a different prop name, such as, inputRef.

Copy link
Member Author

@layershifter layershifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted back to cloneElement and updated handling of ref, also updated tests now everything works as expected. @levithomason thanks for the point to right direction

Copy link
Member

@levithomason levithomason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks!

@levithomason levithomason merged commit a22183e into master Apr 16, 2017
@levithomason levithomason deleted the fix/input-ref branch April 16, 2017 17:00
@levithomason
Copy link
Member

Released in semantic-ui-react@0.68.0.

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

Successfully merging this pull request may close these issues.

3 participants