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

Paparazzi // Jetpack compose // Placeholder is not displayed in the Row #1712

Open
ivk1800 opened this issue Apr 9, 2023 · 4 comments
Open
Labels
help wanted Issues that are up for grabs + are good candidates for community PRs

Comments

@ivk1800
Copy link

ivk1800 commented Apr 9, 2023

Describe the bug
Placeholder is not displayed in tests if there are more than one tests. Important point, AsyncImage is in a Row.

To Reproduce
Here is the test I used to confirm the behavior.
Result:

testContentCompose1: Placeholder is red.
testContentCompose2: Placeholder is not displayed.

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import app.cash.paparazzi.Paparazzi
import coil.compose.AsyncImage
import com.google.accompanist.drawablepainter.rememberDrawablePainter
import org.junit.Rule
import org.junit.Test

internal class RowTest {
    @get:Rule
    val paparazzi = Paparazzi()

    @Test
    fun testContentCompose1() {
        shot()
    }

    @Test
    fun testContentCompose2() {
        shot()
    }

    private fun shot() {
        paparazzi.snapshot {
            Column(
                modifier = Modifier.background(androidx.compose.ui.graphics.Color.Black)
            ) {
                LazyRow(
                    contentPadding = PaddingValues(horizontal = 10.dp),
                    horizontalArrangement = Arrangement.spacedBy(10.dp),
                    verticalAlignment = Alignment.Top,
                    content = {
                        items(3) {
                            CustomImage(modifier = Modifier.size(25.dp),)
                        }
                    },
                )
                Box(modifier = Modifier.height(50.dp))
                CustomImage()
            }
        }
    }

    @Composable
    private fun CustomImage(
        modifier: Modifier = Modifier,
    ) {
        val placeholderDrawable = remember { ColorDrawable(Color.RED) }
        val placeholderPainter = rememberDrawablePainter(placeholderDrawable)
        AsyncImage(
            modifier = modifier.border(1.dp, androidx.compose.ui.graphics.Color.White),
            model = "",
            placeholder = placeholderPainter,
            error = placeholderPainter,
            contentScale = ContentScale.FillBounds,
            contentDescription = null,
        )
    }
}

Logs/Screenshots

testContentCompose1 testContentCompose2
l

Version
coil: 2.2.0, 2.3.0
paparazzi: 1.2.0

@colinrtwhite
Copy link
Member

Thanks for the repro test case! This looks related to #1711. I think removing the mapping here should fix this, though we'll need to make sure removing it doesn't have side effects.

@ivk1800
Copy link
Author

ivk1800 commented Apr 10, 2023

@colinrtwhite btw it is reproduced with custom drawable as

class PlaceholderDrawable() : Drawable() {
...
}

@colinrtwhite
Copy link
Member

Hmm this does look different than #1711 actually.

@colinrtwhite colinrtwhite added the help wanted Issues that are up for grabs + are good candidates for community PRs label May 14, 2023
@yayahassani
Copy link

I have the same issue while showing images in a Row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that are up for grabs + are good candidates for community PRs
Projects
None yet
Development

No branches or pull requests

3 participants