This commit is contained in:
Laux Dev
2026-03-03 10:17:48 +08:00
parent 1b3b669d58
commit e47424771f

View File

@@ -15,18 +15,16 @@ const SelectField = ({ label, options, ...props }) => {
}); });
useEffect(() => { useEffect(() => {
if (showOptions && selectRef.current) { if (!showOptions || !selectRef.current) return;
const rect = selectRef.current.getBoundingClientRect();
const spaceBelow = window.innerHeight - rect.bottom;
const spaceAbove = rect.top;
const dropdownHeight = 150;
if (spaceBelow < dropdownHeight && spaceAbove > dropdownHeight) { const rect = selectRef.current.getBoundingClientRect();
setDropUp(true);
} else { const spaceBelow = window.innerHeight - rect.bottom;
setDropUp(false); const spaceAbove = rect.top;
}
} const dropdownHeight = 150;
setDropUp(spaceBelow < dropdownHeight && spaceAbove > dropdownHeight);
}, [showOptions]); }, [showOptions]);
return ( return (