Keep the slider pill inside its track - #97
Conversation
The pill was pinned to the right edge of the fill by a fixed 20px, and the fill was a plain fraction of the track. At the top of the range that put the pill's right edge 20px past the end of the track, and at the bottom, where the fill has no width at all, it started 15px before the track began. A full-width slider has margin either side to hide that. A slider in a group does not, so the pill drew over the card beside it. Both are inset by the pill now, and by half of it where the fill is concerned. At the top the fill is the whole track, so the bar still reads as full with the pill on the end of it. At the bottom the fill reaches the middle of the pill, so the pill has green behind its left half and nothing shows beside it. Halfway along, both land within a pixel of where they always did. Holding grows the pill from 35 to 41, which both are measured off, so that path moves them too.
There was a problem hiding this comment.
I found two regressions in the new slider geometry that should be fixed before merging.
-
The handle now follows an inset path, but pointer input still maps across the full track. This can change the slider value when a user starts dragging the handle near either end.
-
The new handle-position tween also conflicts with the multi-property held-state tween. A drag update can cancel that tween before the held size and transparency finish.
The bounds fix itself looks sound, and the added tests cover the static geometry. They do not cover these two runtime interaction cases.
Requesting changes for the two inline issues mentioned above.
The pill travels an inset path, half a pill in from each end, but the pointer was still mapped across the whole track. Grabbing the pill at either end moved the value before the drag did anything. - map the pointer over the same inset span, clamping the end caps to the ends of the range - fall back to the whole track when the track is narrower than the pill - split the held tween from the follow: the hold owns Size and the transparencies, _renderProgress owns Position and the fill, so a drag update no longer cancels the grow partway
|
Both fixed.
Specs for both, plus one for the narrow track. The existing drag spec changed with it: at x=150 on a 200px track it's 19 rather than 25, which is (150 - 100 - 41/2) / (200 - 41) with the held pill. |
There was a problem hiding this comment.
Re-checked the latest changes.
The two issues from my previous review are fixed, and the added regression tests cover both cases. The pointer now follows the same inset path as the slider handle, and the held-state tween no longer conflicts with drag updates.
The required Studio validation is documented in the PR, and CI is passing.
I do not see any remaining code issues blocking this PR. Approved on my end.
We will still need @jensonhirst to sign off on the PR. He will be responsible for merging it once he is happy with the changes. LGTM 👍🏽
|
|
Summary
The slider's pill draws outside its own track at both ends of the range. On a full-width slider there is enough margin either side to hide it. On a slider inside a group there is not, so the pill draws over the card beside it.
Related issue
Closes #96
Change type
Changes
src/components/slider.luau: the pill was pinned to the right edge of the fill by a fixed 20px, and the fill was a plain fraction of the track. Both are inset by the pill now, and by half of it for the fill:fillSizereturnsUDim2.new(ratio, (1 - ratio) * width / 2, 1, 0)andhandleOffsetreturnsUDim2.new(1, (1 - ratio) * width / 2, 0.5, 0)._setHeldgrows the pill from 35 to 41, which both are measured off, so that path moves them too. Without it, grabbing a pill at the bottom of the range pushes it back outside the track.Compatibility and breaking changes
Validation
make ci, including the coverage threshold, or explained below why it does not apply.Test scenarios and results
make ci: 230 tests pass, coverage 82.68% against the 82.68% baseline in this branch.Documentation coordination
UI evidence
Before: pills breaking out of their cards at both ends. Music at 0 draws over the card to its left, Prediction and Field Of View Radius at the top of their ranges draw past the right edge, and Jump at the bottom hangs off the left.
After: every pill inside its own card. The bar is full at the top with the pill on the end of it, and at the bottom the fill reaches the middle of the pill with nothing showing beside it. Dragging one to both ends while holding it is at the end of the clip.
Checklist
dev.SiriusSoftwareLtd/docs.roblox.yml,sourcemap.json,globalTypes.d.luau, orbuild/.