From d06285ddaa7be6bb5ae3d44daec8d6e5f7ff939d Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Fri, 24 Apr 2026 17:13:12 +0200 Subject: [PATCH] fix: portal all filter popovers to prevent occlusion by sticky columns --- src/components/ColumnFilterPopover.tsx | 26 +++++--- src/components/PricingView.tsx | 90 +++++++++++++++++++------- 2 files changed, 82 insertions(+), 34 deletions(-) diff --git a/src/components/ColumnFilterPopover.tsx b/src/components/ColumnFilterPopover.tsx index 5e6de0a..28f169c 100644 --- a/src/components/ColumnFilterPopover.tsx +++ b/src/components/ColumnFilterPopover.tsx @@ -32,7 +32,8 @@ export function ColumnFilterPopover({ onClose, title, className, - zIndex = 50 + zIndex = 50, + triggerId }: ColumnFilterPopoverProps) { const [search, setSearch] = useState(''); const [activeTab, setActiveTab] = useState<'values' | 'condition'>('values'); @@ -52,15 +53,16 @@ export function ColumnFilterPopover({ document.body.appendChild(container); setPortalContainer(container); - const btns = document.querySelectorAll('.filter-trigger-btn'); - btns.forEach(btn => { - if (btn instanceof HTMLElement) { - const rect = btn.getBoundingClientRect(); - const currentLeft = rect.left; - const currentTop = rect.bottom + 4; - setPosition({ top: currentTop, left: currentLeft }); + if (triggerId) { + const trigger = document.getElementById(triggerId); + if (trigger) { + const rect = trigger.getBoundingClientRect(); + setPosition({ + top: rect.bottom + window.scrollY + 4, + left: Math.min(rect.left + window.scrollX, window.innerWidth - 300) + }); } - }); + } return () => { if (document.body.contains(container)) { @@ -195,7 +197,11 @@ export function ColumnFilterPopover({ "absolute w-72 bg-slate-800 border border-slate-700 rounded-lg shadow-2xl p-3 flex flex-col gap-3 animate-in fade-in zoom-in-95 duration-100 pointer-events-auto", className )} - style={{ zIndex: 9999 }} + style={{ + zIndex: 9999, + top: position.top - window.scrollY, + left: position.left - window.scrollX + }} onClick={(e) => e.stopPropagation()} >