From 63fca6b5adf7c52c31a6eee9cad61345b197e557 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Thu, 13 Feb 2025 00:57:06 +0100 Subject: [PATCH] fix: Fully optimize rendering of navigations Fallback to vanillaJS due to React taking a significant amount of rendering time when we wanted to only update two classes on the navigation bar. In addition to that, turns out Firefox has a decade-old bug related to history.replaceState that causes it to leak memory. This is a known issue and it's not going to be fixed. Our solution is to just get rid of the history.replaceState and not update the URL when you're scrolling. Tough luck, but hey, not gonna fix a decade old bug for a simple throw-away website. --- src/components/mobile-nav.tsx | 7 +---- src/components/nav.tsx | 59 +++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/components/mobile-nav.tsx b/src/components/mobile-nav.tsx index 5ff9b6d..b4554ed 100644 --- a/src/components/mobile-nav.tsx +++ b/src/components/mobile-nav.tsx @@ -3,18 +3,15 @@ import { Button } from "@/components/ui/button" import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet" import type { Sections, translations } from "@/i18n/translations" -import { cn } from "@/lib/utils" import { Menu } from "lucide-react" import { LanguageSelector } from "./ui/language-selector" export function MobileNav({ t, linksOrder, - activeSection }: { t: typeof translations.pl linksOrder: Array - activeSection: Sections }) { return ( @@ -30,9 +27,7 @@ export function MobileNav({