From dd4cb40667564bde715ecdab699f89ce922cd265 Mon Sep 17 00:00:00 2001 From: wuyangfan Date: Mon, 25 May 2026 10:40:52 +0800 Subject: [PATCH] fix(ui): size bottom-positioned profiler popups using space above button Corner popups anchored to the bottom of the viewport grow upward, but max-height was calculated from the distance below the button. That left too little room when the profiler button was higher on the page. Use the available space above the button for bottom-left/bottom-right positions, and the space below for top positions. Fixes #696 Co-authored-by: Cursor --- src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts b/src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts index fb97d051..6bcc123f 100755 --- a/src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts +++ b/src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts @@ -1054,12 +1054,15 @@ namespace StackExchange.Profiling { // is this rendering on the bottom (if no, then is top by default) if (pos === RenderPosition.BottomLeft || pos === RenderPosition.BottomRight) { - const bottom = window.innerHeight - button.getBoundingClientRect().top - button.offsetHeight + window.scrollY; // get bottom of button popup.style.bottom = '0'; - popup.style.maxHeight = 'calc(100vh - ' + (bottom + 25) + 'px)'; + popup.style.top = ''; + const maxHeight = Math.max(0, button.getBoundingClientRect().top - 25); + popup.style.maxHeight = `${maxHeight}px`; } else { popup.style.top = '0'; - popup.style.maxHeight = 'calc(100vh - ' + (button.getBoundingClientRect().top - window.window.scrollY + 25) + 'px)'; + popup.style.bottom = ''; + const maxHeight = Math.max(0, window.innerHeight - button.getBoundingClientRect().bottom - 25); + popup.style.maxHeight = `${maxHeight}px`; } } return;