Skip to content

fix: resolve navigation memory leaks, component anti-pattern & CSS syntax - #587

Merged
Sammy99jsp merged 4 commits into
Avdan-OS:devfrom
pranav256:fix-nav-and-dynamic-width
Nov 4, 2026
Merged

Sammy99jsp merged 4 commits into
Avdan-OS:devfrom
pranav256:fix-nav-and-dynamic-width

Conversation

@pranav256

Copy link
Copy Markdown
Contributor

Summary

Following the feedback on #586 from @SunightMC and @Sammy99jsp, this pull request isolates the core navigation maintenance and memory leak fixes into a small, focused change without touching any copywriting, design direction, or translations.

Changes

  1. Prevent resize listener leak in dynamic-width.ts:
    • Stores callback in a useRef (savedCallback) so that callers passing inline arrow functions do not trigger listener removal/re-addition on every render.
    • Attaches the resize event listener once on mount with proper removeEventListener cleanup on unmount.
  2. Refactor MenuBar in menu.tsx:
    • Moves MenuBar outside of Menu as a standard React functional component with typed props, removing the class-in-function anti-pattern.
    • Retains exact desktop and mobile tab elements and conditional rendering logic.
  3. Fix CSS block in menu.tsx:
    • Closes the unclosed .header-dark-tabs CSS declaration with the missing closing brace.
  4. Remove unused jQuery CDN tag in _app.tsx:
    • Removes the unused jQuery 3.3.1 script tag.
    • Keeps Bootstrap 5.1.3 JS intact so the mobile navbar collapse (data-bs-toggle="collapse") continues to function properly on phones.

Verification

  • Verified production build and static export pass cleanly (npm run build succeeds across all 18 routes).
  • Verified navigation and responsive collapse behavior.

@SunightMC

SunightMC commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

thanks, this is way better and a lot easier to review. the listener fix checks out (dev ends up with 30 resize listeners after 10 page switches, this stays at 8), and dropping jquery is fine, the mobile menu still works.

one blocker though: moving MenuBar out of Menu brings back the duplicate tab from #586. on first load at desktop width the nav shows two "Features" tabs (one goes to /features, the other to /features-beta), and between 750–1200px "Demo" shows up even though it should be hidden. geist's Tabs (2.3.8) registers tabs by value and never removes them, so when useFeaturesBeta/useMobileBar change after mount, the old tabs stick around. the class component only avoided this by accident because it remounted every render.

giving MenuBar a key fixes it, i tested it and the tabs match dev at every width:

<MenuBar
  key={`${useMobileBar}-${useFeaturesBeta}`}
  ...

push that and i'll be glad to green flag this. also small thing: please actually open the site and resize it before saying navigation was verified, this shows up on the very first page load.

@geeky-lynx

Copy link
Copy Markdown
Contributor

This is mostly fine to me as well. I have no other objections to the changes. I'll just add to not edit your PR's title and description to be named "closed" like you did in #585 and #586, as there's no point doing that.

@pranav256

Copy link
Copy Markdown
Contributor Author

Thanks @SunightMC for catching the Geist \Tabs\ registration quirk and providing the exact key solution! I've added \key={\-\}\ to \MenuBar\ and pushed the commit. Also appreciate the note @geeky-lynx, keeping the PR clean.

@SunightMC

Copy link
Copy Markdown
Member

looks great now, thanks! but one small thing: your PR description got mangled. Tabs shows up as \Tabs\ and the key as key={\-\}. looks like shell escaping, probably the same thing that left the stray `n in #586. the committed code itself is correct, so it doesn't block anything, but please check text that goes through a script before posting it.

personally don't see a reason why this couldn't be merged, so green flagging this 👍

@SunightMC
SunightMC requested a review from Sammy99jsp November 4, 2026 13:43
@geeky-lynx

Copy link
Copy Markdown
Contributor

I gotta ask, which LLM model are you using Pranav?

@Sammy99jsp Sammy99jsp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice that the listener is cleaned up now, and good job with the functional component.

@Sammy99jsp
Sammy99jsp merged commit cb4475d into Avdan-OS:dev Nov 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants