The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): Android chip taps open the chip from either half (#33126)
maria committed
Nov 9, 2026 at 05:18 UTC
61629df695f244b295edfc953b0c57a03bb55217
1 file changed
+21
-2
apps/mobile/modules/t3-composer-editor/android/src/main/java/expo/modules/t3composereditor/T3ComposerEditorView.kt
+21
-2
@@ -134,8 +134,9 @@ class T3ComposerEditorView(context: Context, appContext: AppContext) : ExpoView(
134
val token =
135
tokens.firstOrNull {
136
(it.type == "context" || it.type == "mention" || it.type == "skill") &&
137
- offset >= it.start &&
138
- offset < it.end
137
+ offset in it.start..it.end &&
138
+ it.end <= editor.length() &&
139
+ chipContains(it, event.x, event.y)
140
}
141
?: return false
142
if (token.end <= editor.length() &&
@@ -453,6 +454,24 @@ class T3ComposerEditorView(context: Context, appContext: AppContext) : ExpoView(
454
)
455
}
456
457
+ // A chip is one replacement span, so a tap on its right half reports the offset at its end,
458
+ // and a tap below the last line clamps to it; only the chip's drawn bounds count.
459
+ private fun chipContains(token: ComposerToken, viewX: Float, viewY: Float): Boolean {
460
+ val layout = editor.layout ?: return false
461
+ val x = viewX - editor.totalPaddingLeft + editor.scrollX
462
+ val y = viewY - editor.totalPaddingTop + editor.scrollY
463
+ val line = layout.getLineForOffset(token.start)
464
+ val left = layout.getPrimaryHorizontal(token.start)
465
+ val right =
466
+ if (layout.getLineForOffset(token.end) == line) {
467
+ layout.getPrimaryHorizontal(token.end)
468
+ } else {
469
+ layout.getLineRight(line)
470
+ }
471
+ return y >= layout.getLineTop(line) && y <= layout.getLineBottom(line) &&
472
+ x >= minOf(left, right) && x <= maxOf(left, right)
473
+ }
474
+
475
private fun applyTokenSpans() {
476
val editable = editor.text ?: return
477
editable.getSpans(