New board: theme picker shows Dark selected but the board renders Light #121
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_whiteboard#121
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Open a brand new board. The board content area renders in the Light theme (white canvas, light navbar) but the theme picker in the navbar marks Dark as the currently selected theme. The picker label and the actual rendered state disagree until the user picks any theme manually.
Steps to reproduce
Expected
The picker reflects what is actually rendered on screen, with no manual click required.
Actual
Picker says Dark, board says Light.
Root cause
crates/hero_whiteboard_ui/static/web/js/whiteboard/themes.jsinitializes:init()builds the picker UI but never callsapplyTheme(currentThemeName). The picker readscurrentThemeNameto decide which row is highlighted, so it shows Dark. Meanwhile the chrome/canvas have nothing applied — they fall back to the CSS rule:root:not([data-bs-theme="dark"])(Light) and to the unset canvas container background.app.js::loadBoardonly callsWhiteboardThemes.loadTheme(...)ifboardData.themeis set (i.e. the board has a previously-saved theme). For a brand-new board there is no saved theme, soapplyThemeis never called, and the default-theme name and the rendered state diverge.Fix
Call
applyTheme(currentThemeName, { _fromSync: true })at the end ofinit()so the chrome/canvas always reflect the named default on first paint. The_fromSyncflag suppresses the save-to-server and broadcast so this initial application doesn't spam the network.loadBoard's subsequentloadThemecall still overrides correctly when a saved theme exists.Implementation Spec for Issue #121
Objective
Make the theme picker's "selected" indicator and the actually-rendered state agree on a brand-new board with no saved theme.
Root cause
themes.js::init()builds the picker UI but never applies the default theme. The picker readscurrentThemeName(initialized to'Dark') to decide which row to highlight, while the chrome/canvas have nodata-bs-themeattribute set and no canvas-bg styled, so they fall back to the Light CSS rule.Files to Modify
crates/hero_whiteboard_ui/static/web/js/whiteboard/themes.js— applycurrentThemeNameat the end ofinit()with_fromSync: trueso the initial paint matches the picker without saving or broadcasting.Implementation Plan
Step 1: Apply default theme at init
File:
crates/hero_whiteboard_ui/static/web/js/whiteboard/themes.jsAt the end of
init()(after the picker UI is built), add:Dependencies: none.
WhiteboardCanvas.initruns beforeWhiteboardThemes.initinapp.js::init, so the canvas exists by the timeapplyThemeruns.Acceptance Criteria
board.theme.updatedbroadcast appears in the WebSocket logs on initial page load.cargo fmt,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace --libclean.Notes
_fromSync: true: a passive page load should not write back to the server or broadcast a "theme changed" event over WebSocket. Only an explicit user pick (or a remote pick mirrored via the WS) should do that. Existing receiver paths (sync.js'sboard.theme.updatedhandler) already use_fromSync: true; init() should match.loadBoard'sloadTheme(...)call without_fromSyncis a related minor inefficiency (it re-saves and re-broadcasts the same theme on every page load), but it does not affect the user-visible bug here. Out of scope.Implementation Summary
One-line addition in
themes.js::init()so the rendered state matches the picker label on a brand-new board.crates/hero_whiteboard_ui/static/web/js/whiteboard/themes.js_fromSync: truesuppresses the save-to-server and WS broadcast thatapplyThemewould otherwise do, since this is a passive page load, not a user pick.loadBoardruns after init and still overrides with a saved theme vialoadTheme(...)when the board has one.Files Changed
crates/hero_whiteboard_ui/static/web/js/whiteboard/themes.js—+7 / 0Test Results
cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo test --workspace --lib— 0 failednode --check themes.js— cleanManual smoke
board.theme.updatedbroadcast in WS logs on a passive page load.Notes
loadBoard'sloadTheme(...)call is missing_fromSync: true, so loading a board with a saved theme re-saves and re-broadcasts the same theme. Out of scope here; it doesn't affect the user-visible bug.Iteration: keep Light as the default
Changed the init() call to apply Light explicitly:
Reasoning: the chrome and canvas were already rendering Light by default (CSS fallback when no
data-bs-theme="dark"is set), so the picker should agree with what is actually on screen. New boards continue to look light; only the picker indicator now shows Light highlighted instead of Dark.