Skip to content

fix: Theme toggle icon resets to System icon on page refresh despite active Dark/Light theme #269

Open

Description

@puneetnith28

Summary

Fix the theme toggle icon resetting to the System icon after page refresh.

Issue

The selected theme is saved correctly, but after refreshing the page, the toggle still shows the System icon instead of the Sun or Moon icon.

Root Cause

During SSR, the System icon is rendered by default. During Preact hydration, the existing SVG is reused instead of being replaced with the correct theme icon.

Proposed Fix

Add a key={currentTheme} prop to the trigger icon so Preact's reconciler cleanly replaces the stale server-rendered SVG node during client hydration:

<TriggerIcon key={currentTheme} height="20" />

Activity

  1. puneetnith28 commented on Sep 14, 2026

    @puneetnith28
    ContributorAuthor

    Hello @moshams272
    Could you please review this and let me know if this approach looks good to you?
    I will proceed with the next step once you approve it.
    Thanks !!

  2. avivkeller commented on Sep 15, 2026

    @avivkeller
    Member

    Feel free to open a PR

  3. TusharThakur04 commented on Sep 15, 2026

    @TusharThakur04
    Member

    i think issue is at the doc-kit side

  4. moshams272 commented on Sep 16, 2026

    @moshams272
    Member

    doc-kit uses the ThemeToggle from the @node-core/ui-components package, so we should solve it from the source repo.

    @puneetnith28 solved this in the right way, it just needs to be applied in the source. I'll take care of it. Nice work, buddy 🤍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions