Skip to content

Commit 02e5f7f

Browse files
author
raineer
committed
should appear more centered
1 parent 8faf503 commit 02e5f7f

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎apps/codebility/app/home/interns/_components/FilterCodevs.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,17 @@ export default function FilterCodevs({
7777
useEffect(() => {
7878
if (buttonRef && showFilter) {
7979
const rect = buttonRef.getBoundingClientRect();
80+
const viewportHeight = window.innerHeight;
81+
const dropdownHeight = 450; // Approximate dropdown height
82+
83+
// Check if dropdown would overflow bottom of viewport
84+
const wouldOverflowBottom = rect.bottom + dropdownHeight > viewportHeight;
85+
8086
setDropdownPosition({
81-
top: rect.bottom + 8, // 8px gap below button
87+
// Position above button if would overflow, otherwise below
88+
top: wouldOverflowBottom
89+
? Math.max(60, rect.top - dropdownHeight - 8) // Above with top padding
90+
: rect.bottom + 8, // Below with gap
8291
right: window.innerWidth - rect.right, // Align right edge
8392
});
8493
}
@@ -118,7 +127,7 @@ export default function FilterCodevs({
118127

119128
{/* Filter dropdown panel */}
120129
<div
121-
className="fixed z-50 max-h-[calc(100vh-6rem)] min-h-[300px] w-[90vw] overflow-auto
130+
className="fixed z-50 max-h-[min(70vh,500px)] min-h-[300px] w-[90vw] overflow-auto
122131
sm:w-96 md:w-80 rounded-2xl bg-white/95 backdrop-blur-md p-6 shadow-2xl
123132
dark:bg-gray-900/95 border border-gray-200 dark:border-gray-700"
124133
style={{

0 commit comments

Comments
 (0)