fix(a11y): compliance toggle knob position - #11
Merged
Merged
Conversation
The switch knob span had a vertical anchor (top-0.5) but no horizontal anchor, so left:auto resolved its base position to mid-track (~14px) instead of 0. Measured live: OFF rendered the knob 16px from the track left (reading like ON), and ON pushed the knob to 28px, overflowing the 28px track by 12px (knob off the right edge, looks broken). Add left-0 to the knob so its base is 0. OFF now translates 2px (knob at the left), ON translates 14px (knob right, right edge at 26px, fully inside the 28px track, no overflow). Verified in a headless browser: OFF knob.left - track.left = 2px, ON = 14px, right-overflow 0 in both, aria-checked flips correctly, no console errors. Follow-up to the focus-ring fix shipped in #10. Track, colors, sizes, the translate values, and the focus treatment are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Fixes the Compliance toggle knob geometry in the LabOS top nav. Follow-up to the focus-ring fix merged in #10; that PR cleaned the keyboard focus ring, this one corrects where the knob sits inside the track.
Root cause
In
src/components/shell/ComplianceToggle.tsx, the switch knob span had a vertical anchor (top-0.5) but no horizontal anchor. Withposition: absoluteand noleft/right,leftresolves toauto, placing the knob's base at the static-flow position (~14px, mid-track) instead of 0. Thetranslate-x-*offsets were then applied on top of that wrong base.Measured live before the fix:
aria-checked=false): computedleft: 14px+translate(2px)soknob.left - track.left = 16px. The knob sat on the right, so OFF read like ON.aria-checked=true): computedleft: 14px+translate(14px)soknob.left - track.left = 28px. Knob right edge at 770.66 vs track right 758.66, overflowing the 28px track by 12px (knob off the right edge, looks broken).Fix (one line,
ComplianceToggle.tsxonly)Add
left-0to the knob span so its base position is 0. Everything else is unchanged: track, colors, sizes, thetranslate-x-0.5/translate-x-3.5values, and the focus treatment from #10.Verification (in-browser, Chromium via Playwright, against
next dev)After the fix:
aria-checked=false):knob.left - track.left = 2px(knob at the LEFT), right-overflow 0. Computedleft: 0px,transform: translate(2px).aria-checked=true):knob.left - track.left = 14px(knob at the RIGHT, knob right edge 756.66 inside track right 758.66), right-overflow 0. Computedleft: 0px,transform: translate(14px).aria-checkedand the persistedlocalStoragevalue track state (false/0 to true/1 to false/0).The pre-fix 16px / 28px-overflow numbers above were reproduced live in the same browser by removing the
left-0anchor, confirming the diagnosis.CI parity
npx tsc --noEmit: passnpm run build(Next build): pass, all 9 static pages generated, lint and type step cleanlintscript; Next's build-time check passed.No change to
globals.cssand no change tomcclean.ts.🤖 Generated with Claude Code