Wait out the theme transition before auditing contrast - #42
Merged
Conversation
The a11y gate has been failing at random on contrast, twice now, and both times on the first few headings of a block with nothing wrong with them. Reproduced by throttling the CPU 8x: one run in eight, axe reporting fgColor #1b1a18 against bgColor #15171a, the foreground of the theme being left on the background of the theme being arrived at. Setting data-theme is instant but the colours it implies are not, because app.css transitions color and background-color. reducedMotion 'reduce' collapses that to .01ms, which is a duration and not an absence, so the swap still waits on a frame before anything reads the new colour. On an unloaded machine the old 50ms sleep covered that frame. On a loaded runner it covered nothing. So wait for the thing itself. Two frames to get the change through style, layout and paint, then the transitions it started, awaited by their own promises, with animations left out because a looping one never finishes. Then prove it: body is color: var(--fg), so body's computed colour and the theme's --fg have to agree before the audit runs, and if they ever do not that is what gets reported. Violations now print the data axe already had, the two colours and the ratio, so the next one of these is a diagnosis instead of a selector and a shrug. The note about the July failure is rewritten, since it had cleared the transition and the transition did it. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5e5a689-2285-4421-b2b5-b348df97b055
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.
The
Accessibility and layoutjob has been failing at random oncolor-contrast, most recently on PR #40 where thepull_requestrun failed and thepushrun for the same commit passed. Same shape as an unexplained failure back in July.It reproduces with the CPU throttled 8x. One run in eight, and axe hands over the answer:
#1b1a18is bbb-light's--fg.#15171ais bbb-dark's--bg. That is the foreground of the theme being left measured against the background of the theme being arrived at, on text that has never rendered that way for anyone.Why
Setting
data-themeis instant. The colours it implies are not, becauseapp.csstransitionscolorandbackground-coloronbody.reducedMotion: 'reduce'collapses that to.01ms, which is a duration and not an absence, so the swap still has to wait for a frame before anything reads the new colour. On an unloaded machine that frame is immediate and the oldwaitForTimeout(50)covered it. On a loaded CI runner it is not, and the sleep covered nothing.Both failures landed on the first few headings of a block, which is just what axe reaches first.
The July note in this file had looked at the transition and cleared it, on the reducedMotion reasoning above. That was the wrong conclusion, so it is rewritten with what actually happened and how to reproduce it.
What changed
Nothing in the site.
scripts/a11y.mjsonly.bodyiscolor: var(--fg), so body's computed colour and the applied theme's--fghave to agree before an audit runs. A mismatch reports which two disagree instead of surfacing as a mystery contrast violation.Testing
16 throttled rounds against the same setup that failed on round six of eight, all clean.
pnpm testat 391 passing.