TP-39967 | debounce fix (#169)
This commit is contained in:
committed by
GitHub
parent
3c8fc105bd
commit
aae8a2df69
@@ -216,11 +216,18 @@ fun Modifier.customClickable(
|
||||
MutableSharedFlow<Unit>()
|
||||
)
|
||||
}
|
||||
var lastClickEvent: Long by remember { mutableStateOf(0) }
|
||||
|
||||
LaunchedEffect(clickEvents) {
|
||||
clickEvents.debounce(property.debounceTime.orZero()).collect {
|
||||
onClick()
|
||||
clickEvents.collect {
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - lastClickEvent >= property.debounceTime.orZero()) {
|
||||
onClick()
|
||||
lastClickEvent = now
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clickable(
|
||||
indication = getInteractionType(interaction = property.interaction),
|
||||
interactionSource = remember { MutableInteractionSource() }) {
|
||||
|
||||
Reference in New Issue
Block a user