Conversation
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
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.$lastValidValueto display the current model. Inside theupdateContrastModelfunction, the store update (contrastModelStore.$raw.set(model)) was wrapped within abatch()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
contrastModelStore.$raw.set(model)to execute immediately before thebatch()block in theupdateContrastModelfunction.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