Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sources/SkipUI/Skip/Shadowed.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.ui.graphics.Paint
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp
import kotlin.math.ceil
Expand All @@ -28,7 +29,9 @@ import kotlin.math.ceil
val blurRadiusPx = ceil(with(density) { blurRadius.toPx() }).toInt()

val contentContext = context.content()
// The shadow is a second copy of the content: keep it out of the accessibility tree.
val shadowContext = context.content(modifier = Modifier
.clearAndSetSemantics {}
.drawWithContent {
val matrix = shadowColorMatrix(color)
val filter = ColorFilter.colorMatrix(matrix)
Expand Down
25 changes: 25 additions & 0 deletions Tests/SkipUITests/SkipUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.longClick
import androidx.compose.ui.test.moveTo
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onFirst
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
Expand Down Expand Up @@ -519,6 +520,30 @@ final class SkipUITests: SkipUITestCase {
}
}

func testShadowCopyIsHiddenFromAccessibility() throws {
#if !SKIP
throw XCTSkip("Compose semantics")
#else
try testUI(view: {
Text("Shadowed").shadow(radius: 4)
}, eval: { rule in
rule.onAllNodesWithText("Shadowed").assertCountEquals(1)
})
#endif
}

func testShadowCopyOfButtonIsHiddenFromAccessibility() throws {
#if !SKIP
throw XCTSkip("Compose semantics")
#else
try testUI(view: {
Button("Tap") { }.shadow(radius: 4, y: 8)
}, eval: { rule in
rule.onAllNodes(hasClickAction()).assertCountEquals(1)
})
#endif
}

func testMenuAccessibilityIdentifier() throws {
try testUI(view: {
MenuTestView().accessibilityIdentifier("test-view")
Expand Down
Loading