hello, i use a `Slider` and noticed that the `onV...
# compose
t
hello, i use a
Slider
and noticed that the
onValueChangeFinished
is executed before the
onValueChange
event when i do not drag the slider but simply click on a new location:
Copy code
I/System.out: onValueChangeFinished: 76.77
I/System.out: onValueChange: 15.1843815
when i drag, everything works as expected:
Copy code
...
I/System.out: onValueChange: 72.501526
I/System.out: onValueChange: 72.402824
I/System.out: onValueChange: 72.451195
I/System.out: onValueChange: 72.36809
I/System.out: onValueChange: 72.342735
I/System.out: onValueChange: 72.66811
I/System.out: onValueChangeFinished: 72.66811
is this a known issue? EDIT: moved source snippets to thread.
source snippets:
Copy code
var brightness by remember(dimming.brightness) { mutableStateOf(dimming.brightness) }

...

Slider(
    value = brightness,
    onValueChange = {
        println("onValueChange: $it")
        brightness = it
    },
    modifier = Modifier.weight(1f),
    valueRange = dimming.range,
    onValueChangeFinished = {
        println("onValueChangeFinished: $brightness")
        onLightStateChange.invoke(light.id, light.isOn, brightness)
    }
)
r
There is this issue “Inconsistent order of onValueChange and onValueChangeFinished callbacks from Slider” which is indirectly marked closed (through the one marked its duplicate). Maybe you’re on an old version or this hasn’t really been fixed.
t
thanks for your answer! i will check my version and try to update.
i updated gradle plugin "org.jetbrains.compose" from 1.1.1 to 1.2.0 and now the error is gone. thanks again! :)