diff --git a/web/src/components/MultiSelect.jsx b/web/src/components/MultiSelect.jsx index 226316966..1ff30a231 100644 --- a/web/src/components/MultiSelect.jsx +++ b/web/src/components/MultiSelect.jsx @@ -7,54 +7,65 @@ import Button from './Button'; import CameraIcon from '../icons/Camera'; export default function MultiSelect({ className, title, options, selection, onToggle, onShowAll, onSelectSingle }) { - const popupRef = useRef(null); const [state, setState] = useState({ showMenu: false, }); - const isOptionSelected = (item) => { return selection == "all" || selection.split(',').indexOf(item) > -1; } + const isOptionSelected = (item) => { + return selection == 'all' || selection.split(',').indexOf(item) > -1; + }; const menuHeight = Math.round(window.innerHeight * 0.55); return (
-
setState({ showMenu: true })} - > +
setState({ showMenu: true })}>
{state.showMenu ? ( - setState({ showMenu: false })}> + setState({ showMenu: false })} + >
- {title} -
{options.map((item) => (
-
))}
- ): null} + ) : null}
); } diff --git a/web/src/components/RelativeModal.jsx b/web/src/components/RelativeModal.jsx index 93ebe2a26..6ccfccbe1 100644 --- a/web/src/components/RelativeModal.jsx +++ b/web/src/components/RelativeModal.jsx @@ -57,7 +57,7 @@ export default function RelativeModal({ x: relativeToX, y: relativeToY, width: relativeToWidth, - // height: relativeToHeight, + height: relativeToHeight, } = relativeTo.current.getBoundingClientRect(); const _width = widthRelative ? relativeToWidth : menuWidth; @@ -78,10 +78,13 @@ export default function RelativeModal({ newLeft = windowWidth - width - WINDOW_PADDING; } - // too close to bottom - if (top + menuHeight > windowHeight - WINDOW_PADDING + window.scrollY) { - // If the pop-up modal would extend beyond the bottom of the visible window, - // reposition the modal to appear above the clicked icon instead + // This condition checks if the menu overflows the bottom of the page and + // if there's enough space to position the menu above the clicked icon. + // If both conditions are met, the menu will be positioned above the clicked icon + if ( + top + menuHeight > windowHeight - WINDOW_PADDING + window.scrollY && + top - menuHeight - relativeToHeight >= WINDOW_PADDING + ) { newTop = top - menuHeight; } @@ -89,7 +92,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 below the clicked icon for the menu to fit. + // 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 - top > menuHeight + ? null + : windowHeight - WINDOW_PADDING * 2 - top + window.scrollY; + const newPosition = { left: newLeft, top: newTop, maxHeight }; if (widthRelative) { newPosition.width = relativeToWidth; @@ -115,7 +124,7 @@ export default function RelativeModal({
-
+
Ffprobe Output {state.ffprobe != '' ? (
@@ -175,7 +175,7 @@ export default function System() { {state.showVainfo && ( -
+
Vainfo Output {state.vainfo != '' ? (