My drag events seem to drop from the drag event listeners after the first .dragAndDropTarget() is triggered.
This behavior happened after updating JetpackCompose BOM from “2024.02.00” to “2024.09.00”. I believe it’s Material3’s package versioning going from 1.2.1 -> 1.3.0 which is causing the issue.
Is this a me problem, or a library problem? I viewed their issue tracker but couldn’t find any up-to-date bugs reporting this. Only this old post
Buggy behavior after update here
Working version with Material3 v.1.2.1 here.
//Detect drag events for each card item and updates offset to parent column to create a vertical scroll
Card(
modifier = modifier
.dragAndDropTarget(
shouldStartDragAndDrop = { event -> event.toAndroidDragEvent().localState is TransferHudUiItem },
target = object : DragAndDropTarget {
override fun onStarted(event: DragAndDropEvent) {
super.onStarted(event)
dragStartPosition = event.toAndroidDragEvent().y
}
override fun onMoved(event: DragAndDropEvent) {
super.onMoved(event)
val dragPosition = event.toAndroidDragEvent().y
dragOffset = dragStartPosition - dragPosition
setDragOffset(dragOffset)
}
......//
//Parent Composable which holds the column that consumes the dragOffset
Column(
modifier = modifier
.verticalScroll(scrollState)
.clipToBounds()
.fillMaxSize()
.offset {
IntOffset(
0,
dragOffSet.toInt()
)
}
) {