Skip to content

fix(navigation): clean up leaked global scroll listeners#7617

Open
Manishnemade12 wants to merge 2 commits intolayer5io:masterfrom
Manishnemade12:Uncleaned
Open

fix(navigation): clean up leaked global scroll listeners#7617
Manishnemade12 wants to merge 2 commits intolayer5io:masterfrom
Manishnemade12:Uncleaned

Conversation

@Manishnemade12
Copy link
Copy Markdown

@Manishnemade12 Manishnemade12 commented Apr 11, 2026

Description

Fixes memory leaks caused by uncleaned global scroll listeners in SPA navigation flows.

Closes : #7611

Root Cause

Two components attached window.addEventListener("scroll", ...) using anonymous callbacks inside useEffect without corresponding cleanup, so listeners accumulated across route transitions.

What Changed

  • Added a named handleScroll function and cleanup return in src/sections/General/Navigation/index.js.
  • Added a named handleHeaderScroll function and cleanup return in src/sections/Company/Brand/index.js.
  • Kept changes minimal and scoped only to leak points.

Why This Fix

Using stable function references allows window.removeEventListener(...) on unmount, preventing stacked listeners, memory leaks, and scroll-jank over long sessions.

Validation

  • Manual code audit of scroll/resize listeners across src/**.
  • No functional behavior change intended; only lifecycle cleanup.
  • Tests were not run in this environment (per local workflow).

Signed-off-by: Manishnemade12 <mnemade140@gmail.com>
Signed-off-by: Manish Nemade <166635137+Manishnemade12@users.noreply.github.com>
Signed-off-by: Manishnemade12 <mnemade140@gmail.com>
@rishiraj38
Copy link
Copy Markdown
Member

LGTM!

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.

Fix Memory Leaks Caused by Uncleaned Event Listeners

2 participants