mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 15:05:23 +02:00
fix: improve filter popover positioning and reliability across all views
This commit is contained in:
@@ -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()}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user