android-maps-compose icon indicating copy to clipboard operation
android-maps-compose copied to clipboard

View isn't updated after recomposition

Open Jasperav opened this issue 2 years ago • 16 comments

I have seen it in more complex applications, but this is the easiest reproduction view:

@Composable
fun ClusterItemConversation() {
    val x = remember { mutableIntStateOf(0) }

    LaunchedEffect(key1 = Unit) {
        // This just delays the execution
        dispatchToMainThread(2000) {
            x.value += 1

            log { "Updated" }
        }
    }

    Column(verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally) {
        Text(text = x.value.toString())
    }
}

// Some map code...
Clustering(items = clusterItems, clusterItemContent = { ci ->
    ClusterItemConversation()
})

In the logging I can observe that Updated is there, but the view isn't updated at all, the text remains 0. The view is out of sync.

Jasperav avatar Dec 30 '23 14:12 Jasperav

i think i have a similar issue. the clusterItem is depending on state that is updated but using the clustering we're not able to specify a key like in the MarkerComposable() how are we supposed to define such state objects using a cluster?

cwsiteplan avatar Jan 09 '24 10:01 cwsiteplan

i created a sample for my case here: https://github.com/googlemaps/android-maps-compose/compare/main...cwsiteplan:android-maps-compose:bug/cluster-item-update

i do have a mutable state that holds the ID of the selected marker.

but the clusterItemContent does not get recomposed, even though read state values do change.

@Composable
fun CustomRendererClustering(items: List<MyItem>, selectedId: String) {
...
clusterItemContent = {
            CircleContent(
                modifier = Modifier.size(20.dp),
                text = "",
                color = if (it.id == selectedId) Color.Red else Color.Green,
            )
        },
...
}

cwsiteplan avatar Jan 15 '24 08:01 cwsiteplan

Same issue here. Any work around?

abinhho avatar Jan 16 '24 09:01 abinhho

Any update on this?

yasintanriverdi avatar Jan 24 '24 11:01 yasintanriverdi

Also looking for a solution for this please. Exact same issue as above, I have an isSelected boolean that is getting updated, but the view isn't getting recomposed.

Joshdmi avatar Jan 26 '24 10:01 Joshdmi

Just encountered the same issue here. Can we at least have a workaround for the recomposition, like MarkerComposable did?

yibene avatar Feb 06 '24 08:02 yibene

I also have this issue, I would like to update the clustered marker composables based on user interaction!

simonheng avatar Feb 17 '24 17:02 simonheng

I had the same issue with maps-compose-utils version 4.3.2. Using version 4.2.0 works fine.

ernesto-olalla avatar Feb 23 '24 08:02 ernesto-olalla

I have the same issue with maps-compose-utils version 4.3.3. Any work around except modify data in the items of Clustering composable?

larten avatar Mar 18 '24 09:03 larten

Can we get an ETA of a potential fix? @kikoso

cwsiteplan avatar Mar 25 '24 13:03 cwsiteplan

seems 4.4.0 is fixing this issue for me.

cwsiteplan avatar Apr 26 '24 07:04 cwsiteplan

Hello, Any update on this?

cchaouachi avatar Jul 16 '24 14:07 cchaouachi

Just encountered the same issue here. Can we at least have a workaround for the recomposition, like MarkerComposable did?

@yibene What's the workaround with MarkerComposable? I'm facing the said issue but with MarkerComposable

mddanishansari avatar Jul 23 '24 14:07 mddanishansari

Just encountered the same issue here. Can we at least have a workaround for the recomposition, like MarkerComposable did?

@yibene What's the workaround with MarkerComposable? I'm facing the said issue but with MarkerComposable

Never mind, I used keys argument of MarkerComposable and it works seamlessly

mddanishansari avatar Jul 26 '24 13:07 mddanishansari

Any updates to this issue, I'm facing the same with MarkerComposable

Abdelsattar avatar Jul 29 '24 09:07 Abdelsattar

Hi folks,

This should have been fixed. Are you experiencing this on the MarkerComposable? In this case, what are you using in the keys parameter?

kikoso avatar Aug 09 '24 10:08 kikoso