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(Search): strict validation to avoid errors when not using title #2654

Merged
merged 2 commits into from
Mar 27, 2018

Conversation

eightnoteight
Copy link
Contributor

@eightnoteight eightnoteight commented Mar 17, 2018

Hi,
at here
https://github.com/Semantic-Org/Semantic-UI-React/blob/master/src/modules/Search/Search.js#L375

we are using setValue(result.title), if the title is not a mandatory field then value will be set to undefined, and for my use case i'm getting error here, for checking length attribute of undefined.

https://github.com/Semantic-Org/Semantic-UI-React/blob/master/src/modules/Search/Search.js#L496

@codecov-io
Copy link

Codecov Report

Merging #2654 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2654   +/-   ##
=======================================
  Coverage   99.74%   99.74%           
=======================================
  Files         160      160           
  Lines        2751     2751           
=======================================
  Hits         2744     2744           
  Misses          7        7
Impacted Files Coverage Δ
src/modules/Search/Search.js 99.46% <ø> (ø) ⬆️
src/modules/Search/SearchResult.js 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 54f6cfa...a49da3c. Read the comment docs.

@eightnoteight eightnoteight changed the title fix(modules/Search): strict validation to avoid errors when using title fix(modules/Search): strict validation to avoid errors when not using title Mar 17, 2018
@levithomason
Copy link
Member

I'm afraid I don't quite understand the problem that is being solved. Could you add a failing test or fork https://codesandbox.io/s/2l3n74j9y and demonstrate the issue?

@eightnoteight
Copy link
Contributor Author

eightnoteight commented Mar 18, 2018

https://codesandbox.io/s/y29ol2l22z

video of issue being reproduced:
https://youtu.be/0_vlkmuIxIM

enter any letter and something0 will be search result, now if you select the first result i.e "something0"
internally the value is set to result.title which is undefined as I haven't defined in my result object, the next time when i clicked on the input it tries to rerender at which time we are trying to check currentValue.length this raises an error.

the issue as a whole occurred as we are expecting title to be mandatory field of result object, as you can render a result without mentioning title.

having a stricter validation to make the title as mandatory field will avoid such issues in future.

@levithomason
Copy link
Member

I see, thanks!

@levithomason levithomason changed the title fix(modules/Search): strict validation to avoid errors when not using title fix(Search): strict validation to avoid errors when not using title Mar 27, 2018
@levithomason levithomason merged commit 371c4e4 into Semantic-Org:master Mar 27, 2018
@levithomason
Copy link
Member

Released in semantic-ui-react@0.79.1.

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