Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: Prevent Clustering with composable content from displaying default markers #615

Conversation

darronschall
Copy link
Contributor

Thank you for opening a Pull Request!


Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #569 🦕

@kikoso
Copy link
Collaborator

kikoso commented Aug 29, 2024

Hi @darronschall , and thank you for this PR!

Upon further checking it, it seems that using the two separate SideEffect blocks could have lead to race conditions, hence the reports on why this was not always reproducible. The explicit null check makes also the code safer in case of a race condition.

I am still not able to reproduce it, but this should fix a potential concurrency issue.

@kikoso
Copy link
Collaborator

kikoso commented Aug 29, 2024

Probably fixes #549

@gmazzotta-bit
Copy link

gmazzotta-bit commented Aug 29, 2024

I'd update this too:

val clusterManager = rememberClusterManager<T>()
LaunchedEffect(clusterManager, clusterRenderer) {
clusterManager?.renderer = clusterRenderer
}
SideEffect {
clusterManager ?: return@SideEffect
clusterManager.setOnClusterClickListener(onClusterClick)
clusterManager.setOnClusterItemClickListener(onClusterItemClick)
clusterManager.setOnClusterItemInfoWindowClickListener(onClusterItemInfoWindowClick)
clusterManager.setOnClusterItemInfoWindowLongClickListener(onClusterItemInfoWindowLongClick)
}
if (clusterManager != null) {
Clustering(
items = items,
clusterManager = clusterManager,
)
}

@gmazzotta-bit
Copy link

By the way, as I mentioned here, I really believe this is a bug in DefaultClusterRenderer, but this change should be enough to work around that.

@darronschall darronschall force-pushed the prevent-clustering-from-displaying-default-renderer branch from 9aa32dc to 8757935 Compare November 1, 2024 12:44
…lt markers

Wait until we have both a non-null clusterManager and renderer created before configuring the cluster manager listeners. This is a small optimization that prevents setting the listeners on the default renderer when the clusterManger is first created (before the renderer is created).

Wait until the renderer is created before configuring the map for clustering. This prevents the default renderer from rendering markers.
@darronschall darronschall force-pushed the prevent-clustering-from-displaying-default-renderer branch from 8757935 to fe45cb9 Compare November 1, 2024 12:45
@darronschall
Copy link
Contributor Author

@kikoso I'm sorry for the delay here; got wrapped up in some other things. I finally had a chance to incorporate @gmazzotta-bit's suggestion around updating some additional code in the deprecated ReplaceWith comments.

Rebased this off of main and force pushed for a clean history.

Copy link
Collaborator

@kikoso kikoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @darronschall

@dkhawk dkhawk merged commit 95c6306 into googlemaps:main Nov 5, 2024
10 of 11 checks passed
googlemaps-bot pushed a commit that referenced this pull request Nov 5, 2024
## [6.2.1](v6.2.0...v6.2.1) (2024-11-05)

### Bug Fixes

* Prevent Clustering with composable content from displaying default markers ([#615](#615)) ([95c6306](95c6306))
@googlemaps-bot
Copy link
Contributor

🎉 This PR is included in version 6.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clustering sometimes show default markers
5 participants