Skip to content

fix(funbox): deselecting funbox effects does not reset without refresh (@d1rshan)#7582

Open
d1rshan wants to merge 4 commits intomonkeytypegame:masterfrom
d1rshan:fix/funbox-state
Open

fix(funbox): deselecting funbox effects does not reset without refresh (@d1rshan)#7582
d1rshan wants to merge 4 commits intomonkeytypegame:masterfrom
d1rshan:fix/funbox-state

Conversation

@d1rshan
Copy link

@d1rshan d1rshan commented Mar 6, 2026

When multiple funbox effects were deselected, the UI showed them as disabled but effects
remained active until refresh.

Root cause

  • .funBoxTheme cleanup originally removed only one stylesheet element, so stale funbox
    CSS links could remain in the DOM.
  • Funbox config-change handling did not fully resync runtime DOM/CSS state.
  • The sync helpers were marked async despite doing synchronous DOM work, creating
    microtask yield points.
  • toggleFunbox also manually applied/cleared global effects, which could duplicate
    effects when subscriber sync ran too.

Fix

  • Use qsa(".funBoxTheme").remove() to remove all funbox stylesheet links.
  • Add syncFunboxStateWithConfig() on funbox config events to:
    • clear globals for inactive funboxes
    • recompute fb-* body classes
    • rebuild funbox CSS links
    • apply global CSS for active funboxes
  • Make sync path fully synchronous (setFunboxBodyClasses, applyFunboxCSS,
    syncFunboxStateWithConfig).
  • Remove redundant manual clearGlobal/applyGlobalCSS calls in toggleFunbox to avoid
    duplicate DOM overlays.

Manually verified by enabling multiple funboxes and deselecting them; effects are removed immediately without refresh.

Closes #7468

Copilot AI review requested due to automatic review settings March 6, 2026 10:21
@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Mar 6, 2026
@github-actions github-actions bot added the waiting for review Pull requests that require a review before continuing label Mar 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a UI/state desync in the typing-test “funbox” system where deselecting multiple funbox effects removed UI indicators but left effects active until refresh (by ensuring all injected funbox stylesheets/classes are fully resynced on config changes).

Changes:

  • Remove all .funBoxTheme <link> tags via qsa(...).remove() (instead of only the first match).
  • Add syncFunboxStateWithConfig() and run it on every funbox config event to clear inactive funbox globals, recompute fb-* body classes, and reapply active funbox CSS.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines 223 to 225
"class",
[...new Set([...currentClasses, ...activeFbClasses]).keys()].join(" "),
);
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Body class recompute can leave stale ignore-reduced-motion behind after disabling the last funbox with ignoreReducedMotion because non-fb- classes are preserved. Ensure ignore-reduced-motion is removed from the preserved set before conditionally re-adding it based on active funboxes.

Copilot uses AI. Check for mistakes.
@byseif21
Copy link
Contributor

byseif21 commented Mar 6, 2026

Hi @d1rshan thanks for your contribution, #7575 already fixed the multi selection issue

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

Labels

frontend User interface or web stuff waiting for review Pull requests that require a review before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Funbox deselection does not reset effects without refresh

4 participants