Repository navigation
fix(Slider): horizontal arrow keys follow the mirrored track under RTL - #7461
Conversation
Under RTL the value grows toward the left, so ArrowLeft now increases and ArrowRight decreases on a horizontal track (APG Slider); ArrowUp/ArrowDown, PageUp/PageDown, Home/End and vertical tracks are unchanged. Uses the existing direction helper on the track; red-armed test.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsSlider (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression44 of 448 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 24 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
The implementation looks sound — the new RTL keyboard test fails against the existing Slider and passes with the fix, and vertical sliders plus the Up/Down, Page and Home/End keys are unchanged — but approval waits on a maintainer to provide or identify the governing spec for this behavior. On main, the component:Slider contract records no keyboard behavior and spec:AST-020 makes an APG pattern binding only once a component contract adopts it, so nothing yet settles which horizontal arrow raises the value under RTL. What must be settled is a current record for Slider's RTL arrow mapping (for example, landing the adoption proposed in #7463), which also decides whether this ships as a patch [fix] under spec:AST-017. No code changes are requested in the meantime.
[Automated review]
|
/approve-spec 57be5b1 |
There was a problem hiding this comment.
This change is ready for maintainer approval: the Slider record on main now specifies that a horizontal slider's arrow keys follow the track under right-to-left layouts, and this pull request implements exactly that as a patch fix. The new RTL keyboard test fails against the previous behavior and passes with the fix, and a real-browser check confirms that ArrowLeft now moves the thumb left on an RTL page while left-to-right and vertical sliders behave as before. Nothing further is needed from you.
[Automated review]
Problem
A keyboard user on a right-to-left page moves a horizontal Slider's thumb with the arrow keys and it goes the wrong way: ArrowRight increased the value, but under RTL the track is mirrored and the value grows toward the LEFT, so the thumb visibly moved against the key. The APG Slider pattern ties the horizontal arrows to the track's direction; the pointer path already mirrors (a track click maps to the RTL value), the keyboard did not.
Fix
In the thumb keydown handler, on a horizontal track whose computed direction is RTL (the existing
isRtlElement(track)helper, the same one the pointer mapping uses), ArrowLeft steps towardmaxand ArrowRight towardmin. ArrowUp/ArrowDown, PageUp/PageDown, Home/End, and vertical sliders are unchanged.Evidence
Slider.test.tsx: new "follows the mirrored track under RTL" — ArrowLeft 50→51, ArrowRight →49, ArrowUp →51, ArrowDown →49 with the track's computed direction forced tortl; and "keeps ArrowLeft decreasing on a vertical track under RTL". Red arm: withSlider.tsxreverted to main the first test fails (ArrowLeft produced 49), 74/75; with the fix 75/75 (83/83 across the Slider folder).Changeset
@astryxdesign/corepatch[fix].Record
component:Slider's adoption of the APG Slider pattern (which names this behaviour) is in a separate record pull request; this is the behaviour fix it depends on.