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

"No match found" placeholder is hidden #128

Closed OmanFerrer closed 6 years ago

OmanFerrer commented 6 years ago

Hi, "No match found" placeholder is hidden. See below: select1

Then placeholder appear when I scroll into the popover: select2

That's because popoverHeight it's calculating incorrectly:

const containerHeight =
      (Array.isArray(elementHeight)
        ? elementHeight.reduce((totalHeight, height) => totalHeight + height, 6)
        : elementHeight * (nb2show < menuItems.length ? nb2show : menuItems.length) + 6) || 0;

var popoverHeight = autoCompleteHeight + (containerHeight || noMatchFoundHeight) + footerHeight;

When no results is found, containerHeight has value 6 and noMatchFoundHeight is never setting. I think if you are adding the value 6 on each case (when elementHeight is an array or not), it could be added in popoverHeight's calculation. Then the code would look like this and the problem would be solved:

const containerHeight =
      (Array.isArray(elementHeight)
        ? elementHeight.reduce((totalHeight, height) => totalHeight + height, 0)
        : elementHeight * (nb2show < menuItems.length ? nb2show : menuItems.length)) || 0;

var popoverHeight = autoCompleteHeight + (containerHeight || noMatchFoundHeight) + footerHeight + 6;

Could you consider this solution please? Thank you!!

ghost commented 6 years ago

Any news about this @Sharlaan ?

Sharlaan commented 6 years ago

Fixed with v1.8.10

Enjoy :p

ghost commented 6 years ago

You're a f... genius!! Thx :smile:

Sharlaan commented 6 years ago

Correction: @OmanFerrer is the genius :)