You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello 馃憢馃徑, DragSelectState behaves very weird when item list isn't static.
For an example, I'm fetching data from on-device database(Room) using the following:
val deletedPhotos by localPhotoViewModel.repository.allCameraTrashedPhotos.collectAsState(emptyList())
val dragSelectState = rememberDragSelectState<PhotoEntity>(compareSelector = { it.uid!! })
Now drag-select works fine when data loads for the first time. But when some more rows are added/deleted from database, then sometimes drag-select selects incorrect item, or sometimes can't select/de-select items.
I'm not sure whether I'm doing something wrong, or whether there is an issue in library. Here is how I'm rendering images:
items(photos.size) { index ->
val isSelected by remember {
derivedStateOf { dragSelectState.isSelected(photos[index]) }
}
PhotoItemContent(
item = photos[index],
inSelectionMode = dragSelectState.inSelectionMode,
isSelected = isSelected,
modifier = Modifier
// Add semantics for accessibility
.semantics {
if (!dragSelectState.inSelectionMode) {
onLongClick("Select") {
dragSelectState.addSelected(photos[index])
true
}
}
}
// If we are in selection mode allow the item to be toggleable
.then(
if (dragSelectState.inSelectionMode) {
Modifier.toggleable(
value = isSelected,
interactionSource = remember { MutableInteractionSource() },
indication = null, // do not show a ripple
onValueChange = { toggled ->
if (toggled) dragSelectState.addSelected(photos[index])
else dragSelectState.removeSelected(photos[index])
}
)
} else {
Modifier.clickable {
onClickPhotoItem(navController, photos[index])
}
},
)
)
}
Please let me know if you can help here or need more info.
I have also attached a recording of the user experience here:
WhatsApp.Video.2024-01-06.at.23.47.37.mp4
The text was updated successfully, but these errors were encountered:
I have no timeline or estimate on my end. I can only work on this in my spare time, but I am open to contributions if you wanted to take a crack at it.
I'll attempt to fix it. However I'm still a hobby Android programmer, and learning it since last ~6 months. So can't be sure about it. I'll raise a PR if I'm able to fix it.
Hello 馃憢馃徑, DragSelectState behaves very weird when item list isn't static.
For an example, I'm fetching data from on-device database(Room) using the following:
Now drag-select works fine when data loads for the first time. But when some more rows are added/deleted from database, then sometimes drag-select selects incorrect item, or sometimes can't select/de-select items.
I'm not sure whether I'm doing something wrong, or whether there is an issue in library. Here is how I'm rendering images:
Please let me know if you can help here or need more info.
I have also attached a recording of the user experience here:
WhatsApp.Video.2024-01-06.at.23.47.37.mp4
The text was updated successfully, but these errors were encountered: