Skip to content

Fix contrast model toggle not updating its own button state#60

Merged
psd-coder merged 1 commit intomainfrom
fix-55
Feb 11, 2026
Merged

Fix contrast model toggle not updating its own button state#60
psd-coder merged 1 commit intomainfrom
fix-55

Conversation

@psd-coder
Copy link
Copy Markdown
Member

Overview

Fixed a UI bug where the contrast model toggle button did not update its displayed value immediately when clicked, even though the underlying model was being updated correctly.

Problem Statement

When users clicked the contrast model toggle button (switching between "apca" and "wcag"), the button text did not update to reflect the new value. The button remained showing the old contrast model value until other UI updates occurred, creating a confusing user experience where the button appeared unresponsive despite the action being processed.

The root cause was in the reactive state management flow. The button subscribed to contrastModelStore.$lastValidValue to display the current model. Inside the updateContrastModel function, the store update (contrastModelStore.$raw.set(model)) was wrapped within a batch() call alongside the conversion of all level contrast values. When updates are batched, the signals framework defers subscriber notifications until the batch completes. This meant the button wouldn't see the store update until all level contrasts had been converted, causing a noticeable delay in the button's visual feedback.

Solution Approach

  • Moved store update outside batch: Relocated contrastModelStore.$raw.set(model) to execute immediately before the batch() block in the updateContrastModel function.
    • This allows the contrast model store to update and notify subscribers (including the toggle button) immediately
    • The button now reflects the new value as soon as the user clicks it
    • The subsequent batched operations (converting level contrasts from APCA to WCAG or vice versa) still benefit from batched processing but no longer block the button's UI update

Breaking Changes

None. This is a bug fix that improves UI responsiveness without changing any public APIs or behavior beyond fixing the visual state update timing.

fixes #55

Set the contrast model signal before the batch so its reactive value
is updated immediately, fixing the WCAG/APCA button appearing stale
until another interaction triggers a re-render.

Fixes #55
@psd-coder psd-coder self-assigned this Feb 11, 2026
@github-actions
Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit f8d7a47):

https://harmonizer-web--pr60-fix-55-47b7ykkq.web.app

(expires Wed, 18 Feb 2026 02:02:59 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 0b46b8946d697564b3f98633c5cd230a6ede1236

@psd-coder psd-coder merged commit 14da694 into main Feb 11, 2026
5 checks passed
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.

Pressing WCAG / APCA button does not update.

1 participant