Skip to content

Fix resize event listener target in useTocHighlight - #8782

Open
ShakilUrRehman21 wants to merge 1 commit into
reactjs:mainfrom
ShakilUrRehman21:fix-toc-resize-listener
Open

ShakilUrRehman21 wants to merge 1 commit into
reactjs:mainfrom
ShakilUrRehman21:fix-toc-resize-listener

Conversation

@ShakilUrRehman21

Copy link
Copy Markdown
Contributor

Fix resize event listener target in useTocHighlight

Summary

In src/components/Layout/useTocHighlight.tsx, the resize event listener was attached to document instead of window.

In the DOM, resize events are dispatched on window and do not fire on document, so resizing the browser window never triggered throttledUpdateActiveLink to recalculate the active Table of Contents heading.

This PR attaches and cleans up the resize listener on window.

How was this tested?

  • Ran npx tsc --noEmit (passed with 0 errors).
  • Verified Prettier formatting on src/components/Layout/useTocHighlight.tsx.
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Five Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/404 119.1 KB (🟡 +3 B) 234.28 KB
/500 119.11 KB (🟡 +3 B) 234.29 KB
/[[...markdownPath]] 121.6 KB (🟡 +3 B) 236.78 KB
/errors 119.36 KB (🟡 +3 B) 234.54 KB
/errors/[errorCode] 119.33 KB (🟡 +3 B) 234.51 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

This branch was successfully deployed

1 active deployment
Preview — 3ce5fe49 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant