Skip to content

fix(footer): remove back-to-top listeners on unmount - #479

Merged
hivecommons-hive[bot] merged 3 commits into
mainfrom
scanner/fix-478
Oct 26, 2026
Merged

hivecommons-hive[bot] merged 3 commits into
mainfrom
scanner/fix-478

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Closes #478

Footer's back-to-top useEffect added a window scroll listener and an anonymous click listener without a cleanup, so every mount leaked both. Name the click handler and remove both listeners in the effect cleanup, mirroring DocsFooter. Adds an unmount regression test and a changelog fragment.

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for hivecommons-docs failed. Why did it fail? →

Name Link
🔨 Latest commit dc9b328
🔍 Latest deploy log https://app.netlify.com/projects/hivecommons-docs/deploys/6adef95b85e55c7f2ffc33d5

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: 0ea9ca3

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 26, 2026
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added size/S and removed size/M labels Oct 26, 2026
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 26, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Code is correct; the only blocker is a Prettier formatting failure in the new test.

Read src/components/Footer.tsx at 54997d5 in full. The effect now returns initBackToTop(), which yields either undefined (early return at Footer.tsx:26 when #back-to-top is absent) or the cleanup closure at Footer.tsx:51-54, which removes the same two listener references that were added at Footer.tsx:45-46. Both are valid useEffect return values, and because handleClick is now a named const the removeEventListener("click", …) actually matches the registered handler — the original anonymous arrow could never have been removed. The [] deps mean this runs once per mount, so the leak described in #478 is closed. Existing scroll/click tests in Footer.behavior.test.tsx are untouched and still pass (Vitest run 40282091067 green).

Why "TypeScript & ESLint" is red (run 40282091120, Prettier step):

[warn] src/__tests__/Footer.behavior.test.tsx
[warn] Code style issues found in the above file. Run Prettier with --write to fix.

The failure appeared with the second commit (54997d5); the first commit (3aa14e3) passed the same job. The culprit is the new assertion at src/__tests__/Footer.behavior.test.tsx:227 — expect(windowRemoveSpy).toHaveBeenCalledWith("scroll", expect.any(Function)); is over the 80-column print width, so Prettier wants it wrapped. npx prettier --write src/__tests__/Footer.behavior.test.tsx and a push should turn the job green; no logic change needed.

The Netlify deploy-preview / header / redirect / pages failures are the known free-tier quota exhaustion ruled on in #419, not something this PR can fix.

I have not approved or changed anything.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The fix is correct; the red TypeScript & ESLint check is this PR's own Prettier violation, not infra.

Code read against the PR head (54997d5):

  • src/components/Footer.tsx:38-56 — handleClick is now named, both listeners are attached and then removed in the returned cleanup, and useEffect receives that cleanup via return initBackToTop() at line 59. When #back-to-top is absent, initBackToTop returns undefined, which React accepts as "no cleanup". Behaviour on mount is unchanged (toggleButton() initial check still runs). Looks correct to me.
  • src/__tests__/Footer.behavior.test.tsx:220-229 — the unmount test spies on the real button element the effect bound to, so the removeEventListener("click", …) assertion exercises the actual cleanup path.

Why CI is red (job 121437427142, step "Prettier"): prettier --check . flags src/__tests__/Footer.behavior.test.tsx. Line 227 is 81 characters:

    expect(windowRemoveSpy).toHaveBeenCalledWith("scroll", expect.any(Function));

.prettierrc sets printWidth: 80, so Prettier wants it wrapped. The same check is green on main, so this is introduced by the diff. One-line fix on the branch: npx prettier --write src/__tests__/Footer.behavior.test.tsx and push.

The Netlify deploy-preview / header / redirect / pages-changed failures are the known team-quota exhaustion (see docs#419) and are unrelated to this change.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: Prettier line-width fix pushed; netlify/* checks are the known quota incident (#419). CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: dc9b328

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@kubestellar-prow kubestellar-prow Bot added size/M and removed size/S labels Oct 26, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 26, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The Prettier blocker from the previous review is resolved; the fix itself is unchanged and looks correct to me.

Read at head dc9b328:

  • dc9b328 is formatting-only: it wraps the windowRemoveSpy assertion at src/__tests__/Footer.behavior.test.tsx:225-228. prettier --check on both touched source files passes locally, and the TypeScript & ESLint job (121439187697) is now green along with Vitest, Build and npm audit.
  • src/components/Footer.tsx:38-59 is identical to the previously reviewed head: handleClick is named so removeEventListener("click", handleClick) at line 54 matches the handler registered at line 46; the scroll listener is removed at line 53; return initBackToTop() at line 59 hands React either the cleanup or undefined (early return at line 26 when #back-to-top is absent). Matches the pattern in DocsFooter the body cites, and closes the leak described in #478.

The remaining red checks are all the Netlify deploy-preview group (Header rules, Redirect rules, Pages changed, deploy-preview), which fail on every docs PR at present and are unrelated to this diff.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Head dc9b328 resolves the only blocker from the previous round; the change looks correct to me.

  • The new commit touches just src/__tests__/Footer.behavior.test.tsx:227-230, wrapping the 81-char assertion that prettier --check rejected at 54997d5. TypeScript & ESLint, Run unit tests and Lint and build are now green on this head.
  • src/components/Footer.tsx:38-57 is unchanged since the prior read: handleClick is a named const, both listeners are removed in the returned cleanup, and useEffect receives it via return initBackToTop() (line 59). The pattern is byte-for-byte the one already used in src/components/docs/DocsFooter.tsx:71-75, as the body states.
  • The remaining red checks (netlify/hivecommons-docs/deploy-preview, Header rules, Pages changed, Redirect rules) are the Netlify-side failures that affect every PR in this repo; they are not caused by this diff.

Nothing further from me; ready for a maintainer.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 52812d5 into main Oct 26, 2026
6 of 11 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-478 branch October 26, 2026 07:04
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#479dc9b328` sha256:4d81fd2bf4419aa202e7eea0d59a29bc32094a5422eadc2f067eb9aa46c7793f — download from the dashboard or `hivectl review evidence #479`.

@hivecommons-hive hivecommons-hive Bot removed the role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) label Oct 26, 2026
@hivecommons-hive hivecommons-hive Bot removed the stage/050-review-pending Review swarm requested; awaiting a verdict for the current head label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] Footer back-to-top effect never removes its scroll/click listeners

0 participants