Skip to content

fix(ui): resolve theme toggle icon hydration mismatch - #9160

Open
moshams272 wants to merge 1 commit into
nodejs:mainfrom
moshams272:fix/theme-toggle-hydration
Open

moshams272 wants to merge 1 commit into
nodejs:mainfrom
moshams272:fix/theme-toggle-hydration

Conversation

@moshams272

@moshams272 moshams272 commented Sep 16, 2026

Copy link
Copy Markdown

Description

This PR fixes a visual hydration mismatch bug in the ThemeToggle component, which currently causes the theme icon to get stuck on nodejs.org/learn pages (powered by doc-kit). Other pages avoid this issue because their hydration is handled by next-themes.

By adding a key={currentTheme} prop to TriggerIcon, we force React/Preact to remount the correct SVG node on theme changes, rather than incorrectly attempting to reuse the stale server-rendered SVG.

Thanks @puneetnith28 for initially proposing this fix in webpack/webpack-doc-kit/pull/270.

Validation

Can not validate it solves it or not, but can validate the issue. As when click on learn it always goes to the nodejs.org/learn.

Related Issues

None.

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run pnpm format to ensure the code follows the style guide.
  • I have run pnpm test to check if all tests are passing.
  • I have run pnpm build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

@moshams272
moshams272 requested a review from a team as a code owner September 16, 2026 13:20
@vercel

vercel Bot commented Sep 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
nodejs-org Ready Ready Preview Sep 16, 2026 1:21pm UTC

Request Review

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.

2 participants