web: Components: Fixed using maxHeight parameter if there are less elements than specified in parameter for DropDown component

This commit is contained in:
Ilya Oleshko 2019-11-05 16:42:17 +03:00
parent 3632adfcc3
commit 00b421556b

View File

@ -94,7 +94,9 @@ class DropDown extends React.PureComponent {
render() {
const {maxHeight, withArrow, directionX, children} = this.props;
const dropDownMaxHeightProp = maxHeight ? { height: maxHeight + 'px' } : {};
const fullHeight = children.length * 36;
const calculatedHeight = (fullHeight < maxHeight) ? fullHeight : maxHeight;
const dropDownMaxHeightProp = maxHeight ? { height: calculatedHeight + 'px' } : {};
//console.log("DropDown render");
return (
<StyledDropdown
@ -105,7 +107,7 @@ class DropDown extends React.PureComponent {
{withArrow && <Arrow directionX={directionX} />}
{maxHeight
? <FixedSizeList
height={maxHeight}
height={calculatedHeight}
width={this.state.width}
itemSize={36}
itemCount={children.length}