library: drop interactionBarrier from the result overlay (#ux-audit)
- Commit
369a98a6beb33f044207a19a8edc3c538b847a19- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-13 07:39 UTC (23 days ago)
- Parents
ed10892
Follow-up to 72a916529. Modifier.interactionBarrier() is not on
library/ui's compile classpath: library/ui resolves Compose UI 1.12.1
from the BOM (only some app classpaths pull 1.13.0-beta01), so
:library:ui:compileDebugKotlin failed with "Unresolved reference
'interactionBarrier'".
The overlay goes back to hiding the board through its pane: the root
carries semantics { paneTitle }, which makes it important for
accessibility, and Compose's accessibility delegate leaves out every
node wholly covered by an important node drawn above it. The focus
fix from 72a916529 stays: the root is a focus group with an onExit
guard, and focus rests on a dedicated focus target inside it, so the
guard actually runs (Compose only calls onExit on a group whose
descendant holds focus).
The TalkBack test's failure message now includes the reachable virtual
ids and the unmerged semantics tree, so a regression shows why.
Verification: :library:ui:testDebugUnitTest, :library:ui:detekt,
callers' compileDevKotlin.Diff
library/ui/src/main/java/com/vayunmathur/library/ui/game/GameResultOverlay.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/game/GameResultOverlay.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/game/GameResultOverlay.ktindex 3675a2941b..9c3250bc90 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/game/GameResultOverlay.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/game/GameResultOverlay.kt@@ -25,7 +25,6 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier-import androidx.compose.ui.interactionBarrier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusProperties import androidx.compose.ui.focus.focusRequester@@ -53,11 +52,11 @@ import com.vayunmathur.library.ui.TextButton * The scrim is also a touch barrier: it swallows every pointer event that lands outside the card, so a * tap meant to dismiss nothing cannot fall through to a cell or a number-pad key on the finished board. *- * It is modal for assistive technology and keyboards too. The overlay is a pane titled [title], announced- * when it appears, and the scrim is an interaction barrier: the board it covers drops out of the tree- * TalkBack sees, so swiping cannot reach a cell whose click action would bypass the touch barrier, and- * keyboard focus cannot land on it. Focus moves onto the overlay when it appears and cannot leave it, so- * Tab and the D-pad stay on the card's buttons.+ * It is modal for assistive technology and keyboards too. The overlay is a pane titled [title]: it is+ * announced when it appears, and because a pane is important for accessibility and covers the board,+ * Compose leaves the covered board out of the tree TalkBack sees, so swiping cannot reach a cell whose+ * click action would bypass the touch barrier. Focus moves onto the overlay when it appears and cannot+ * leave it, so Tab and the D-pad stay on the card's buttons. * * [won] only picks the title colour; the caller supplies the words, because "Solved", "Field Cleared" * and "Congratulations" all mean the same thing in different games and none of them belongs here.@@ -105,11 +104,10 @@ fun GameResultOverlay( Box( Modifier .matchParentSize()- .interactionBarrier() .swallowPointerInput(), )- // Where focus rests while the overlay shows. Drawn above the barrier, so the barrier does not- // count it as covered, and inside the pane, so the pane's exit guard holds it.+ // Where focus rests while the overlay shows: inside the pane, so the pane's exit guard holds it.+ // The guard only runs for a group whose descendant has focus, never for a focused node itself. Box( Modifier .matchParentSize()@@ -186,8 +184,11 @@ fun GameResultOverlay( } /**- * The pane half of being modal: announced by [title], and a focus group that will not let focus leave.- * Hiding the board itself is the scrim's interaction barrier.+ * The accessibility and focus half of being modal.+ *+ * A pane title makes the node important for accessibility, and Compose leaves out of the accessibility+ * tree any node wholly covered by an important node drawn above it — that is what hides the board from+ * TalkBack. The node is also a focus group that refuses to let focus leave it. */ private fun Modifier.modalPane(title: String): Modifier = this .semantics { paneTitle = title }
library/ui/src/test/java/com/vayunmathur/library/ui/game/GameResultOverlayTest.kt
diff --git a/library/ui/src/test/java/com/vayunmathur/library/ui/game/GameResultOverlayTest.kt b/library/ui/src/test/java/com/vayunmathur/library/ui/game/GameResultOverlayTest.ktindex 50882cadbb..48d2a2184c 100644--- a/library/ui/src/test/java/com/vayunmathur/library/ui/game/GameResultOverlayTest.kt+++ b/library/ui/src/test/java/com/vayunmathur/library/ui/game/GameResultOverlayTest.kt@@ -27,7 +27,9 @@ import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick+import androidx.compose.ui.test.onRoot import androidx.compose.ui.test.performTouchInput+import androidx.compose.ui.test.printToString import androidx.compose.foundation.text.BasicText import androidx.test.core.app.ApplicationProvider import com.vayunmathur.library.ui.R as UiR@@ -111,7 +113,11 @@ class GameResultOverlayTest { val titleId = rule.onNodeWithText("Solved").fetchSemanticsNode().id val reachable = reachableIds(view) assertTrue(titleId in reachable, "the card itself stays reachable")- assertFalse(behindId in reachable, "the covered board is out of the accessibility tree")+ assertFalse(+ behindId in reachable,+ "the covered board is out of the accessibility tree; reachable=$reachable behind=$behindId\n" ++ rule.onRoot(useUnmergedTree = true).printToString(),+ ) } @Test