Open anakiK1to opened 1 year ago
Can you please provide a reproducible sample project o GitHub? Or just a block of code here in comments
Sorry to keep you waiting for an answer, simple version of code will look like that
@Composable
fun slider() {
val interactionSource = remember { MutableInteractionSource() }
val isPressed by interactionSource.collectIsPressedAsState()
val isDragged by interactionSource.collectIsDraggedAsState()
val sliderValue by remeber { mutableStateOf(0f) }
Column{
Slider(
enabled = true,
value = sliderValue,
onValueChange = { newValue ->
sliderValueRaw = newValue},
valueRange = 0F..100f,
interactionSource = interactionSource
)
Text(
text = Text("isPressed: ${isPressed} || isDragged: ${isDragged}"
)
}
}
in this example isPressed never becomes true, but isDragged works correctly I'm not sure if isPressed is supposed to work on Slider, however for me it was the expected behavior
I guess I have similar issue but slightly different use case.
I have a OutlinedTextField acting as DropDown but instead opens a ModalBottomSheet when clicked. So, I'm listening for interactions
from MutableInteractionSource
trying to invoke onClick when the ineraction
is PressInteraction.Release
.
This code is working well with Android and iOS but not on Desktop (tested in Mac).
Use the following composable as a reproducer: https://gist.github.com/sdzshn3/4f14132222df30151b4bec6ab84d4e79
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Describe the bug Trying to handle isPressed interaction with composable slider i encountered a problem thats its never returns true, it seems to me, thats it's because isDragged fireing first and my click recognaized like very fast drag -> release i'm not sure if this behavior is intended, but for it's more like a bug
Affected platforms
Tested on Desktop
### Versions
To Reproduce
Expected behavior I expecteed isPressed to return true when tap on it's line/ point, and expected isDragged to return true when slider's thumb is dragged and false when dragged ends