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(Dropdown): do not close on click when search is empty #1490

Merged
merged 3 commits into from
Mar 25, 2017

Conversation

rajchourasia
Copy link
Contributor

Fixes #1451 . Mimics the behaviour of SUI core in similar scenario.

@codecov-io
Copy link

codecov-io commented Mar 21, 2017

Codecov Report

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

@@            Coverage Diff             @@
##           master    #1490      +/-   ##
==========================================
+ Coverage   99.74%   99.74%   +<.01%     
==========================================
  Files         141      141              
  Lines        2371     2378       +7     
==========================================
+ Hits         2365     2372       +7     
  Misses          6        6
Impacted Files Coverage Δ
src/modules/Dropdown/Dropdown.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 3fd65da...d7ee5bb. Read the comment docs.

@layershifter layershifter changed the title fix(Dropdown):handle click on dropdown when search result is empty fix(Dropdown): handle click on dropdown when search result is empty Mar 23, 2017
return this.close(e)
}
}
return this.open(e)
Copy link
Member

Choose a reason for hiding this comment

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

Can we simplify logic there?

toggle = (e) => {
  if (this.state.open) {
    this.open(e)
    return
  }

  const { search } = this.props
  const options = this.getMenuOptions()

  if (search && _.isEmpty(options)) {
    e.preventDefault()
    return
  }

  this.close(e)
}

It looks more readable to me.

@levithomason
Copy link
Member

Thanks for writing a test for this as well. This is a good stop-gap for now, however, the SUI core dropdown still allows toggling an empty search dropdown when the icon is clicked:

http://g.recordit.co/QrNPOXFFtr.gif

We should address that at some point.

@levithomason levithomason changed the title fix(Dropdown): handle click on dropdown when search result is empty fix(Dropdown): do not close on click when search is empty Mar 25, 2017
@levithomason levithomason merged commit 014596f into Semantic-Org:master Mar 25, 2017
@levithomason
Copy link
Member

levithomason commented Mar 25, 2017

Released in [email protected].

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.

4 participants