Skip to content

fix(chat): widen the back button's tap area in the chat top bar - #1543

Merged
bmc08gt merged 1 commit into
code/cashfrom
fix/chat-back-hit-target
Sep 23, 2026
Merged

bmc08gt merged 1 commit into
code/cashfrom
fix/chat-back-hit-target

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

In a chat, back is a 40dp circle at 15–55dp and the avatar, which opens the profile, starts at 70dp. The strip between them and the corners around the circle did nothing, so a thumb that missed the arrow either did nothing or, reaching further right, opened the profile. Taps anywhere before the avatar now go back.

Modifier.expandedTouchTarget(outset, onTap)

New in :ui:core. It grows an element's tap area by outset without changing its layout. An inner layout grows by the outset so the tap handler covers it, and an outer layout reports the original size to the parent and pulls the grown box back into place. The control's own click still takes taps inside it and consumes the up, so a tap there fires once.

Two things to know when using it:

  • Put it ahead of any clip in the chain, since a clip also clips hit testing.
  • A clickable under 48dp already takes taps up to its 48dp minimum, and those near hits go to the control rather than onTap. That's harmless when both do the same thing, which is the intended use.

Compose 1.12's PointerInputModifierNode.touchBoundsExpansion looks like the tool for this, but NodeCoordinator.isInExpandedTouchBounds only honours it for stylus and eraser pointers, so a finger never reaches it.

Chat top bar

AppBarDefaults.leadingControlTouchOutset() sizes the outset for a leading control: to the bar's leading edge, its full height, and across the gap up to where the title starts. ConversationTitleBar applies it to back. The bar's 56dp height and 5dp slot padding became named constants so the helper and TopAppBarBase can't drift apart.

The avatar keeps its own bounds, so a tap that lands on the avatar still opens the profile. If that remains a problem, the next step is more space between the arrow and the avatar, which is a design change.

Tests

  • ExpandedTouchTargetTest: taps on the control, just outside it, in the outset, past the parent's edge and past the outset, plus a check that the parent still measures the control at 40dp.
  • ConversationTitleBarTest: a tap in the gap at 62dp goes back and doesn't open the profile, a tap near the circle's corner goes back, and a tap on the arrow goes back exactly once.

In a chat, back is a 40dp circle at 15-55dp and the avatar, which opens
the profile, starts at 70dp. The strip between them and the corners
around the circle did nothing, so a thumb that missed the arrow either
did nothing or, reaching further right, opened the profile.

Add Modifier.expandedTouchTarget(outset, onTap) to :ui:core. It grows an
element's tap area by an outset without changing its layout: an inner
layout grows by the outset so the tap handler covers it, and an outer
layout reports the original size to the parent. The control's own click
still takes taps inside it and consumes the up, so a tap there fires
once.

Compose 1.12's PointerInputModifierNode.touchBoundsExpansion looks like
the tool for this, but NodeCoordinator.isInExpandedTouchBounds only
honours it for stylus and eraser pointers, so a finger never reaches it.

AppBarDefaults.leadingControlTouchOutset() sizes the outset for a
leading control: to the bar's leading edge, its full height, and across
the gap up to where the title starts. The chat bar applies it to back.
The avatar keeps its own bounds, so a tap on the avatar itself still
opens the profile.
@bmc08gt bmc08gt self-assigned this Sep 23, 2026
@github-actions github-actions Bot added type: fix Bug fix area: ui Compose UI, theme, components, resources labels Sep 23, 2026
@bmc08gt
bmc08gt merged commit dce635a into code/cash Sep 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui Compose UI, theme, components, resources type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant