Sharlaan / material-ui-superselectfield

multiselection autocomplete dropdown component for Material-UI
https://sharlaan.github.io/material-ui-superselectfield
MIT License
266 stars 92 forks source link

Fix issue where ids of 0 would be ignored in itemsLength #104

Closed jwmann closed 6 years ago

jwmann commented 6 years ago

In the example/demos shown in the repo, they use id's of 0 (which I suppose could be valid) Anyway, I found a discrepancy where the menu wouldn't open if it had less than 2 items. I found this strange and found that the util function getChildrenLength() had a reduce function that would count based on the 'value' of the child, in this case, this would be the id. Since the id was actually 0 it would count as a false and skip the count.

I've added a check specifically for 0 and it works as it should.

I've also added some tests for future use-cases.

codecov-io commented 6 years ago

Codecov Report

Merging #104 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #104   +/-   ##
======================================
  Coverage    39.5%   39.5%           
======================================
  Files           6       6           
  Lines         200     200           
======================================
  Hits           79      79           
  Misses        121     121
Impacted Files Coverage Δ
src/utils.js 36% <100%> (ø) :arrow_up:

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 b3f6824...a0a60f5. Read the comment docs.