cashapp / paparazzi

Render your Android screens without a physical device or emulator
https://cashapp.github.io/paparazzi/
Apache License 2.0
2.28k stars 214 forks source link

Incorrect contentDescriptions when using AccessibilityRenderExtension with clickable nodes #1440

Closed shorner5 closed 4 months ago

shorner5 commented 4 months ago

Description When a node is clickable, and its child uses clearAndSetSemantics, semantics are not cleared. When the parent is NOT clickable, the semantics are cleared correctly.

Steps to Reproduce Add a test where the parent is clickable, and a child clears its children's semantics:

class ScreenshotTest {
    @get:Rule
    val paparazzi = Paparazzi(
        renderExtensions = setOf(AccessibilityRenderExtension())
    )

    @Test
    fun contentDescriptionTest() {
        paparazzi.snapshot {
            Box(modifier = Modifier.clickable {}) {
                Column(
                    modifier = Modifier.clearAndSetSemantics {
                        contentDescription = "OVERRIDDEN CONTENT DESCRIPTION"
                    }
                ) {
                    Text(text = "Text")
                }
            }
        }
    }
}

Expected behavior The content description should be "OVERRIDDEN CONTENT DESCRIPTION": expected

Actual result Paparazzi renders the content description as "Text, OVERRIDDEN CONTENT DESCRIPTION". actual

TalkBack announces only "OVERRIDDEN CONTENT DESCRIPTION", and Layout Inspector shows that the Box's contentDescription is correct.

Screenshot 2024-05-20 at 1 35 37 PM

Additional information: