fix: improve filter popover positioning and reliability across all views

This commit is contained in:
Christian Vidal Wolf
2026-04-25 09:14:25 +02:00
parent f0f78a6126
commit a2bb2f2307
7 changed files with 54 additions and 21 deletions
+16 -5
View File
@@ -2067,16 +2067,27 @@ function TextFilterPopover({ value, onChange, onClose, triggerId }: {
}) {
const [position, setPosition] = useState({ top: 0, left: 0 });
useEffect(() => {
const updatePosition = useCallback(() => {
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)
left: Math.min(rect.left + window.scrollX, window.innerWidth + window.scrollX - 300)
});
}
}, [triggerId]);
useEffect(() => {
updatePosition();
window.addEventListener('scroll', updatePosition, true);
window.addEventListener('resize', updatePosition);
return () => {
window.removeEventListener('scroll', updatePosition, true);
window.removeEventListener('resize', updatePosition);
};
}, [updatePosition]);
const addTerm = () => {
if (value.terms.length < 5) {
onChange({ ...value, terms: [...value.terms, ''] });
@@ -2101,10 +2112,10 @@ function TextFilterPopover({ value, onChange, onClose, triggerId }: {
return createPortal(
<div
className="fixed z-[9999] w-72 bg-slate-800 border border-slate-700 rounded-lg shadow-2xl p-4 flex flex-col gap-4 animate-in fade-in zoom-in-95 duration-100"
className="absolute z-[9999] w-72 bg-slate-800 border border-slate-700 rounded-lg shadow-2xl p-4 flex flex-col gap-4 animate-in fade-in zoom-in-95 duration-100"
style={{
top: position.top - window.scrollY,
left: position.left - window.scrollX
top: position.top,
left: position.left
}}
onClick={e => e.stopPropagation()}
>