From cbb99f70e4fc3a1aa67e83b9b3b64d94117a4648 Mon Sep 17 00:00:00 2001 From: Bernt Christian Egeland Date: Wed, 12 Apr 2023 18:17:41 +0200 Subject: [PATCH] remove top from the equations due to scroll height --- web/src/components/RelativeModal.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/src/components/RelativeModal.jsx b/web/src/components/RelativeModal.jsx index 93ebe2a26..b45b96a07 100644 --- a/web/src/components/RelativeModal.jsx +++ b/web/src/components/RelativeModal.jsx @@ -89,7 +89,13 @@ export default function RelativeModal({ newTop = WINDOW_PADDING; } - const maxHeight = windowHeight - WINDOW_PADDING * 2 > menuHeight ? null : windowHeight - WINDOW_PADDING * 2; + // This calculation checks if there's enough space to display the menu. + // If there is, it sets the maxHeight to null(meaning no height constraint). If not, it calculates the maxHeight based on the remaining space in the window + const maxHeight = + windowHeight - WINDOW_PADDING * 2 > menuHeight + ? null + : windowHeight - WINDOW_PADDING * 2 - top + window.scrollY; + const newPosition = { left: newLeft, top: newTop, maxHeight }; if (widthRelative) { newPosition.width = relativeToWidth;