Skip to content

Commit 0b72f97

Browse files
brunoborgesCopilot
andcommitted
Auto-flip dropdown menus below button when near viewport top
When opening category/JDK filter dropdowns, measure available space above the button. If insufficient, flip the menu to open below instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d2db7d8 commit 0b72f97

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

site/app.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@
242242

243243
const openDropdown = () => {
244244
list.style.display = 'block';
245+
// Flip dropdown below button if not enough space above
246+
const rect = toggleBtn.getBoundingClientRect();
247+
const listHeight = list.offsetHeight;
248+
if (rect.top < listHeight + 12) {
249+
list.style.bottom = 'auto';
250+
list.style.top = 'calc(100% + 6px)';
251+
} else {
252+
list.style.top = 'auto';
253+
list.style.bottom = 'calc(100% + 6px)';
254+
}
245255
toggleBtn.setAttribute('aria-expanded', 'true');
246256
};
247257

0 commit comments

Comments
 (0)