[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View isn't updated after recomposition #490

Open
Jasperav opened this issue Dec 30, 2023 · 16 comments
Open

View isn't updated after recomposition #490

Jasperav opened this issue Dec 30, 2023 · 16 comments
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@Jasperav
Copy link
Jasperav commented Dec 30, 2023

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 Jasperav added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 30, 2023
@cwsiteplan
Copy link

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
Copy link

i created a sample for my case here: 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,
            )
        },
...
}

@abinhho
Copy link
abinhho commented Jan 16, 2024

Same issue here. Any work around?

@yasintanriverdi
Copy link

Any update on this?

@Joshdmi
Copy link
Joshdmi commented Jan 26, 2024

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.

@yibene
Copy link
yibene commented Feb 6, 2024

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

@simonheng
Copy link

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

@ernesto-olalla
Copy link
ernesto-olalla commented Feb 23, 2024

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

@larten
Copy link
larten commented Mar 18, 2024

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?

@cwsiteplan
Copy link

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

@cwsiteplan
Copy link

seems 4.4.0 is fixing this issue for me.

@cchaouachi
Copy link

Hello,
Any update on this?

@mddanishansari
Copy link

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
Copy link

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

@Abdelsattar
Copy link

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

@kikoso
Copy link
Collaborator
kikoso commented Aug 9, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests