Skip to content

Commit ef9f7db

Browse files
committed
fix: filter overlay
1 parent e3524bb commit ef9f7db

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

apps/dashboard/app/(main)/websites/[id]/_components/filters-section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export function FiltersSection() {
226226
}
227227

228228
return (
229-
<div className="slide-in-from-top-2 animate-in overflow-hidden border-x border-b bg-card shadow-sm duration-300">
229+
<div className="slide-in-from-top-2 animate-in overflow-hidden border-b bg-card duration-300">
230230
{editingFilter && (
231231
<div className="border-amber-200/50 border-b bg-gradient-to-r from-amber-50/80 to-amber-50/40 px-2 py-2 text-amber-900 text-xs sm:px-4 sm:py-3 sm:text-sm">
232232
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-0">

apps/dashboard/app/(main)/websites/[id]/layout.tsx

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,26 @@
33
import { useQueryClient } from "@tanstack/react-query";
44
import { useAtom } from "jotai";
55
import { useParams, usePathname } from "next/navigation";
6+
import { useLayoutEffect, useRef, useState } from "react";
67
import { toast } from "sonner";
78
import NotFound from "@/app/not-found";
89
import { useTrackingSetup } from "@/hooks/use-tracking-setup";
910
import { isAnalyticsRefreshingAtom } from "@/stores/jotai/filterAtoms";
1011
import { AnalyticsToolbar } from "./_components/analytics-toolbar";
1112
import { FiltersSection } from "./_components/filters-section";
1213

13-
interface WebsiteLayoutProps {
14+
type WebsiteLayoutProps = {
1415
children: React.ReactNode;
15-
}
16+
};
1617

1718
export default function WebsiteLayout({ children }: WebsiteLayoutProps) {
1819
const { id } = useParams();
1920
const pathname = usePathname();
2021
const queryClient = useQueryClient();
2122
const { isTrackingSetup } = useTrackingSetup(id as string);
2223
const [isRefreshing, setIsRefreshing] = useAtom(isAnalyticsRefreshingAtom);
23-
24-
if (!id) {
25-
return <NotFound />;
26-
}
27-
28-
const websiteId = id as string;
24+
const toolbarRef = useRef<HTMLDivElement>(null);
25+
const [toolbarHeight, setToolbarHeight] = useState(88);
2926

3027
const isAssistantPage =
3128
pathname.includes("/assistant") ||
@@ -35,6 +32,34 @@ export default function WebsiteLayout({ children }: WebsiteLayoutProps) {
3532
pathname.includes("/settings") ||
3633
pathname.includes("/users");
3734

35+
useLayoutEffect(() => {
36+
const element = toolbarRef.current;
37+
if (!element || isAssistantPage || !isTrackingSetup) {
38+
setToolbarHeight(0);
39+
return;
40+
}
41+
42+
const updateHeight = () => {
43+
const height = element.getBoundingClientRect().height;
44+
setToolbarHeight(height);
45+
};
46+
47+
updateHeight();
48+
49+
const resizeObserver = new ResizeObserver(updateHeight);
50+
resizeObserver.observe(element);
51+
52+
return () => {
53+
resizeObserver.disconnect();
54+
};
55+
}, [isTrackingSetup, isAssistantPage]);
56+
57+
if (!id) {
58+
return <NotFound />;
59+
}
60+
61+
const websiteId = id as string;
62+
3863
const handleRefresh = async () => {
3964
setIsRefreshing(true);
4065
try {
@@ -59,7 +84,10 @@ export default function WebsiteLayout({ children }: WebsiteLayoutProps) {
5984
return (
6085
<div className="flex h-full flex-col overflow-hidden">
6186
{isTrackingSetup && !isAssistantPage && (
62-
<div className="fixed top-12 right-0 left-0 z-50 flex-shrink-0 space-y-0 bg-background md:top-0 md:left-84">
87+
<div
88+
className="fixed top-12 right-0 left-0 z-50 shrink-0 space-y-0 bg-background md:top-0 md:left-84"
89+
ref={toolbarRef}
90+
>
6391
<AnalyticsToolbar
6492
isRefreshing={isRefreshing}
6593
onRefresh={handleRefresh}
@@ -70,7 +98,12 @@ export default function WebsiteLayout({ children }: WebsiteLayoutProps) {
7098
)}
7199

72100
<div
73-
className={`${isAssistantPage ? "min-h-0 flex-1" : isTrackingSetup && !isAssistantPage ? "min-h-0 flex-1 overflow-y-auto pt-[88px] md:pt-[88px]" : "min-h-0 flex-1 overflow-y-auto"}`}
101+
className={`${isAssistantPage ? "min-h-0 flex-1" : isTrackingSetup && !isAssistantPage ? "min-h-0 flex-1 overflow-y-auto" : "min-h-0 flex-1 overflow-y-auto"}`}
102+
style={
103+
isTrackingSetup && !isAssistantPage
104+
? { paddingTop: `${toolbarHeight}px` }
105+
: undefined
106+
}
74107
>
75108
{children}
76109
</div>

0 commit comments

Comments
 (0)