LearnNewsExamplesServices
Frontmatter
id19902
titleThe Portal's theme switch does nothing on its first click
stateClosed
labels
bughelp wantedgood first issuehacktoberfestaiportal
assigneesabhinav-rb
createdAtOct 20, 2026, 1:13 PM
updatedAtOct 21, 2026, 12:00 PM
githubUrlhttps://github.com/neomjs/neo/issues/19902
authorneo-opus-ada
commentsCount2
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined1
signals[]
blockedBy[]
blocking[]
closedAtOct 21, 2026, 12:00 PM

The Portal's theme switch does nothing on its first click

Closed v13.3.0/archive-v13-3-0-chunk-2 bughelp wantedgood first issuehacktoberfestaiportal
neo-opus-ada
neo-opus-ada commented on Oct 20, 2026, 1:13 PM

Claim it first: comment on this issue before you start, and check the open pull requests for one that already points here. We merge the first approve-worthy PR (see CONTRIBUTING.md, point 3).

Corrected 2026-10-21: the first version named only half of the trigger. The bug needs BOTH no stored portalTheme AND a light color-scheme preference. With a stored theme, or with dark mode, the first click works. Context, The Architectural Reality and the ACs now say so.

Context

Welcome! This is a small fix in the Portal, the app behind neomjs.com (apps/portal). You need a fork, Node and the dev server; no Agent OS, Docker or AI tooling.

Found in release testing, 2026-10-20, with headless Chrome on a fresh profile. Headless Chrome reports prefers-color-scheme: light, and that is the second half of the trigger. The Portal loads in its dark theme, and the header's theme button shows a moon. The first click changes the icon but keeps the dark background. Only the second click switches to light.

Measured on neomjs.com, 2026-10-21, one fresh headless context per row:

stored portalTheme color scheme first click
none light stays dark, icon moon → sun
none dark dark → light
neo-theme-neo-dark light dark → light
neo-theme-neo-light light light → dark

Who sees it: a first-time visitor whose OS or browser is set to light, on their first click only. That click stores portalTheme, so every later visit works. Anyone who has clicked the button before, or uses dark mode, never sees it.

The Problem

On that path, the first click asks for the theme that is already showing.

The Architectural Reality

  • apps/portal/neo-config.json: "themes": ["neo-theme-neo-dark", …], so the Portal boots dark.
  • apps/portal/view/ViewportController.mjs#onConstructed sets viewport.theme from a stored portalTheme, or to dark when Neo.config.prefersDarkTheme is true. With neither, it sets nothing.
  • #onSwitchTheme: oldTheme = viewport.theme || 'neo-theme-neo-light'. On that third path viewport.theme is unset, so the method assumes light and "switches" to dark.
  • apps/portal/view/HeaderToolbar.mjs starts the button with iconCls: 'fa-solid fa-moon'.
  • Why: #8855 made dark the default by reordering themes in neo-config.json, a one-line change. The light fallback (from #8727) and the moon icon still assume the old light default.

The Fix

When viewport.theme is unset, fall back to the theme the app actually booted with (the first entry of themes) instead of a hardcoded light. Make sure the button's starting icon matches that theme.

Acceptance Criteria

  • AC-1: with no stored portalTheme and a light color-scheme preference, one click on the theme button switches dark → light, and a second click switches back.
  • AC-2: on that path, the button's icon matches the theme on screen before and after each click.

Out of Scope

  • Following the OS's light or dark preference. The dark default is deliberate.

Related

  • apps/portal/view/ViewportController.mjs, apps/portal/view/HeaderToolbar.mjs.

unowned-rationale: a good first issue for an outside contributor; a maintainer reviews the pull request.

Live latest-open sweep: checked the latest 20 open issues at 2026-10-20T11:12Z, plus an open-issue search for "theme switch first click": no equivalent. MC sweep: no prior decision. Own-assignment sweep: none overlapping.

Origin Session ID: ad84dc14-8baf-4f95-a7dd-a9e224f51c31

tobiu referenced in commit d9785f7 - "fix(portal): theme switch works on the first click after a fresh load (#19940) on Oct 21, 2026, 12:00 PM
tobiu closed this issue on Oct 21, 2026, 12:00 PM