Anyone else experiencing this issue migrating from...
# compose
m
Anyone else experiencing this issue migrating from M2 to M3 Slider? I’m getting the
onValueChangeFinished
called as soon as the first step is dragged to (even though not released). The drag event then cannot proceed further. https://issuetracker.google.com/issues/232597954#comment5 Note: M2 Slider worked without any problem.
Copy code
val speedState = speedPref.stateFlowIncludingDefaults().collectAsStateWithLifecycle()
val dynamicSpeedState = remember(speedState.value) {
    mutableFloatStateOf(speedState.value.toFloat())
}
Slider(
    value = dynamicSpeedState.floatValue,
    onValueChange = { speed ->
        dynamicSpeedState.floatValue = speed
    },
    onValueChangeFinished = {
        // This is called as soon as the value changes even though user still dragging. However, the drag stops at the
        // first step.
        // Note: commenting out the following code means the drag can continue beyond the first step
        scope.launch {
            speedPref.write(dynamicSpeedState.floatValue.toInt())
        }
    },
    valueRange = minSpeed.toFloat()..maxSpeed.toFloat(),
    steps = (maxSpeed - minSpeed) / incSpeed - 1,
    modifier = Modifier.padding(start = 60.dp, end = 8.dp),
    enabled = enabled,
)
This has been fixed in compose 1.6.3 and was reported here: https://issuetracker.google.com/issues/322269951