fix: portal all filter popovers to prevent occlusion by sticky columns

This commit is contained in:
Christian Vidal Wolf
2026-04-24 17:13:12 +02:00
parent e96d245f59
commit d06285ddaa
2 changed files with 82 additions and 34 deletions
+16 -10
View File
@@ -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()}
>
<button