Skip to content

Improve the slider implementation used in range questions#7216

Open
grzesiek2010 wants to merge 9 commits into
getodk:masterfrom
grzesiek2010:COLLECT-7189
Open

Improve the slider implementation used in range questions#7216
grzesiek2010 wants to merge 9 commits into
getodk:masterfrom
grzesiek2010:COLLECT-7189

Conversation

@grzesiek2010
Copy link
Copy Markdown
Member

@grzesiek2010 grzesiek2010 commented May 4, 2026

Closes #7189

Why is this the best possible solution? Were any other approaches considered?

So far, the built-in Compose Slider was responsible for handling all interactions, including dragging, click events, and calculating the current value. This led to some issues, including the one described in the issue, caused by our inability to properly support null values, which forced us to use a workaround.

Adding more hacks or workarounds on top of the existing solution no longer made sense, so I switched to a fully custom slider implementation.

I don’t think this is important enough to justify the risk of including it in v2026.2. Let’s take the time to test it properly and target the v2026.3 release instead.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

The way the slider is rendered and how interactions are handled has changed, so we need to perform full regression testing of this functionality.

Do we need any specific form for testing your changes? If so, please attach one.

Any form with range queston + diffrent parameters.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No.

Before submitting this PR, please make sure you have:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • added any new strings with date formatting to DateFormatsTest
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@grzesiek2010 grzesiek2010 marked this pull request as ready for review May 4, 2026 22:12
@grzesiek2010 grzesiek2010 requested a review from seadowg May 4, 2026 22:12
Copy link
Copy Markdown
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before getting into the code too much, here are a couple of things I'd like to tweak here now we're not under time constraints with this, and we have a completely custom implementation:

  1. Can we "flatten" the end edge of the "progress" bar so that it touches the thumb? Currently, it looks awkward rounding off just before:
Image
  1. Can we remove the start/end ticks? I think we already have a visual anchor provided by the start/end of the bar itself and the current version just kind of looks accidental:
Image
  1. Let's add @Preview functions to make this easier to iterate on in future.

@grzesiek2010
Copy link
Copy Markdown
Member Author

grzesiek2010 commented May 11, 2026

Can we "flatten" the end edge of the "progress" bar so that it touches the thumb? Currently, it looks awkward rounding off just before:

Done.

Let's add @Preview functions to make this easier to iterate on in future.

Done.

Can we remove the start/end ticks? I think we already have a visual anchor provided by the start/end of the bar itself and the current version just kind of looks accidental:

The current implementation aligns with how the built-in one looks. See: https://m3.material.io/components/sliders/specs#anatomy, so I don't think we should remove it.

@grzesiek2010 grzesiek2010 requested a review from seadowg May 11, 2026 12:47
@seadowg
Copy link
Copy Markdown
Member

seadowg commented May 14, 2026

The current implementation aligns with how the built-in one looks. See: https://m3.material.io/components/sliders/specs#anatomy, so I don't think we should remove it.

Not quite:

Screenshot 2026-05-14 at 09 48 25

The Material examples have much larger padding on the extreme end which makes it look more intentional. That said, I don't think I've ever actually seen the ticks used like this in the Android system apps: if there's that much padding it doesn't really make sense as the last tick! I'm not sure what's going on there. I'd still vote for just ditching them and keeping the intermediate ones.

This might be a good thing to get an opinion from @nicoleorlowski on.

Copy link
Copy Markdown
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicoleorlowski
Copy link
Copy Markdown

nicoleorlowski commented May 14, 2026 via email

Copy link
Copy Markdown
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking awesome! One last tweak I want to discuss: I'm noticing that trying to slide the thumb when it's at either end is hard as we're within the back gesture zones. I'm wondering if we should add system gesture inset padding here? It definitely doesn't look as good, but it does make it easier to use.

Image

@grzesiek2010
Copy link
Copy Markdown
Member Author

This is looking awesome! One last tweak I want to discuss: I'm noticing that trying to slide the thumb when it's at either end is hard as we're within the back gesture zones. I'm wondering if we should add system gesture inset padding here? It definitely doesn't look as good, but it does make it easier to use.

Instead of adding padding (which would change the look), I've used systemGestureExclusion on the slider track. This tells the system that this specific area should handle touch events itself, even if it's within the system gesture zones. This way, we keep the edge-to-edge look while making it easy to grab the thumb at the ends.

@grzesiek2010 grzesiek2010 requested a review from seadowg May 18, 2026 13:44
Copy link
Copy Markdown
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Digging into the different slider implementations, there's a lot of duplicated code and constants (sizes, margins etc.). I'm thinking we might want more shared Composables with an "orientation" arg that does things like switch which dimension goes on width vs height. Another trick might be to extract shared modifier extensions.

@grzesiek2010 grzesiek2010 force-pushed the COLLECT-7189 branch 2 times, most recently from 9d33120 to 2f6e810 Compare June 1, 2026 11:36
@grzesiek2010
Copy link
Copy Markdown
Member Author

Digging into the different slider implementations, there's a lot of duplicated code and constants (sizes, margins etc.). I'm thinking we might want more shared Composables with an "orientation" arg that does things like switch which dimension goes on width vs height. Another trick might be to extract shared modifier extensions.

Done.

@grzesiek2010 grzesiek2010 requested a review from seadowg June 1, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Range thumb jumps to start when range is tapped

3 participants