-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix RangeSlider renders track when track colors are transparent
#162386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix RangeSlider renders track when track colors are transparent
#162386
Conversation
| sliderTheme.inactiveTrackColor ?? | ||
| theme.colorScheme.primary.withOpacity(0.24); | ||
| final double effectiveTrackHeight = | ||
| effectiveActiveTrackColor != Colors.transparent && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the other Slider fix PR(#161814), it seems only when both track colors are transparent, we set the height to 0. But here it looks like as long as one of the track colors is transparent, we set the height to 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it checks if both active and inactive colors are transparent.
I moved the check into BaseRangeSliderTrackShape to match with #161814. That's why I conditional look slightly different now. It was returning height when colors isn't transparent but in the base shape, we don't need to return regular height :)
0cf0615 to
aea6a1a
Compare
RangeSlider thumbs cannot reach extreme endsRangeSlider renders track when track colors are transparent
|
|
||
| // If the track colors are transparent, then override only the track height | ||
| // to maintain overall Slider width. | ||
| if (sliderTheme.activeTrackColor == Colors.transparent && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for your patience!
I tested this change locally, but seems if we only set one of the track color to transparent, we still cannot reach the 2 ends and somehow when I ran the sample app on macOS, the thumb is really hard to get focused and dragged.
Screen.Recording.2025-02-12.at.12.27.35.AM.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please share the code sample from this video? It could be the default thumb padding, which cannot be customized without setting the overlay radius to zero in RangeSlider, as shown in the PR sample. A few months ago, I added a new Slider.padding property so we don't have to override the overlay size to get rid default thumb padding. This isn't available in RangeSlider yet.
The reason it could be difficult to focus and drag the thumb is that, as the issue author uses a SizedBox to constrain the track heigh as a result the track height constrained and is much smaller than the thumbs. This is a sample issue, can be tested without this PR.
However, constrained SizedBox isn't required to reproduce this bug so I've updated the PR description with new sample.
aea6a1a to
c5a50bf
Compare
|
Rebased to resolve commit conflict. |
aa7729f to
76f1d21
Compare
QuncCccccc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM:) Sorry for the late response.
Description
Fixes
Sliderwith transparent track colors and customtrackHeightcannot reach the extreme ends but forRangeSlider.Code Sample
expand to view the code sample
Before
After
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.