Repository navigation
Make InfoBubble follow the marker's icon and keep its entry stable - #10
Merged
Merged
Conversation
InfoBubble(marker) and InfoBubbleCustom registered the entry built on first composition inside DisposableEffect(marker) (Custom: marker, tailOffset). The entry's icon is a value, so swapping marker.icon left the bubble placed for the old icon: a pin scaled 2x was drawn over by its own bubble. All three overloads now go through RegisterInfoBubble: the entry is remembered on what decides where the bubble goes (anchor, icon, tailOffset) and is swapped only when one of those changes; its content reads the latest lambda through rememberUpdatedState, so content and colours follow without touching bubbleFlow. Disposal removes only the entry this call put there. Adds a JVM unit test that runs the Compose runtime on a no-node applier (kotlinx-coroutines-test for Main, isReturnDefaultValues for android.os.Trace).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compose already re-ran the content lambda, so content and colours followed. What did not follow was the marker's icon: InfoBubble(marker) registered in DisposableEffect(marker), so after marker.icon was replaced the bubble stayed placed for the old icon's size (doubling the icon put the bubble over the pin).
The three overloads now share a private RegisterInfoBubble: the entry is remembered on where it is shown (marker or position, icon, tailOffset) and replaced only when one of those changes; the content calls the latest lambda via rememberUpdatedState; disposal removes only the entry it added. API dump unchanged.
Tests: InfoBubbleRegistrationTest (4) on a UI-less Applier; the icon test fails on the old code. Adds kotlinx-coroutines-test as a test dependency. Device (Lenovo tablet, MapLibre): after doubling the icon the bubble now moves above the larger pin.