From 05bb49fbc8c70c356dac15ea2cc636a91dd89e1c Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk Date: Thu, 13 Feb 2025 01:19:29 +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 | 60 ++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 31 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({