Skip to content

Commit

Permalink
Adjusted max height for select boxes (#916)
Browse files Browse the repository at this point in the history
- Max Height of 450px
- In case max height exceeds the size of the view port, then we decrease the size of the dropdown

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
  • Loading branch information
bexsoft authored Aug 6, 2024
1 parent 9bfd79f commit 81a517d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/DropdownSelector/DropdownSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const DropdownBlock = styled.div<DropDownBlockProps>(
lightV2.white,
),
padding: 8,
maxHeight: 450,
minWidth: useAnchorWidth ? 160 : 0,
overflowX: "hidden",
overflowY: "auto",
Expand Down Expand Up @@ -177,6 +176,18 @@ const calcElementPosition = (
returnItem.width = bounds.width;
}

//max height of dropdown

let defaultMaxHeight = 450;
returnItem.maxHeight = defaultMaxHeight;

const calcHeight =
window.innerHeight - bounds.top - bounds.height - defaultMaxHeight;

if (calcHeight < 0) {
returnItem.maxHeight = window.innerHeight - bounds.top - bounds.height - 40;
}

return returnItem;
};

Expand Down

0 comments on commit 81a517d

Please sign in to comment.