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

GoogleMap Composable breaks layout in Preview #212

Closed
claytongreen opened this issue Oct 18, 2022 · 5 comments · Fixed by #213
Closed

GoogleMap Composable breaks layout in Preview #212

claytongreen opened this issue Oct 18, 2022 · 5 comments · Fixed by #213
Labels
released type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@claytongreen
Copy link
Contributor

A previous issue #128 and pull request #179 fix the Compose preview breaking when using a GoogleMap composable.
But the layout in the preview is still incorrect as any of the modifiers passed to the GoogleMap are discarded with the early return.

For example:

Column(Modifier.fillMaxSize()) {
    GoogleMap(Modifier.weight(1f))
    SomeExampleContent()
}

result

A possible fix could be instead of a bare return when in preview, GoogleMap could return a Box that keeps the modifiers.

// When in preview, early return a Box with the received modifier preserving layout
if (LocalInspectionMode.current) {
    return Box(modifier = modifier)
}

I have a commit (7e103f5) ready to go, but the pull request said to make an issue first.

Thanks

@claytongreen claytongreen 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 Oct 18, 2022
@arriolac
Copy link
Member

@claytongreen that's how I would fix it, too. Feel free to open a pull request with that fix.

@wangela
Copy link
Member

wangela commented Oct 20, 2022

Since this changes the return type, do users of this library have to change their code when using the GoogleMap composable? i.e., is it a breaking change?

@arriolac
Copy link
Member

Ah yeah it should be:

// When in preview, early return a Box with the received modifier preserving layout
if (LocalInspectionMode.current) {
    Box(modifier = modifier)
    return
}

@claytongreen
Copy link
Contributor Author

Good catch!
Change has been pushed

@googlemaps-bot
Copy link
Contributor

🎉 This issue has been resolved in version 2.7.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

4 participants