Skip to content

fix(conversation): keep message bubble in place during reaction menu overlay - #2257

Merged
mpretty-cyro merged 11 commits into
session-foundation:devfrom
igotlinux:fix/message-reaction-overlay-position
Nov 30, 2026
Merged

mpretty-cyro merged 11 commits into
session-foundation:devfrom
igotlinux:fix/message-reaction-overlay-position

Conversation

@igotlinux

Copy link
Copy Markdown
Contributor

First time contributor checklist

  • I have tested my contribution on these devices:
  • Android Emulator (Pixel, Android 14 / API 34), playDebug
  • Android Physical Device, playDebug
  • My contribution is fully baked and ready to be merged as is
  • I ensure that all the open issues my contribution fixes are mentioned in the commit message of my first commit using the Fixes #1234 syntax

Description

Previously, when long-pressing a message in the conversation view to open the reaction bar and context menu, ConversationReactionOverlay forcefully shifted the bubble across the screen (snapping it to margin edges), scaled down the bubble snapshot, and ran translation/scaling animations. This displaced the message away from the user's touch and from its position in the chat list.

This PR aligns the overlay interaction with standard modern messaging UX (like WhatsApp / Telegram):

  1. Keeps the message bubble in place: The bubble remains at its exact pixel location (bubbleX, bubbleY) in local coordinates at 1.0f scale, without translation or scale animations.
  2. Dynamic reaction bar placement: Intelligently placed right above the message bubble when space permits, or below if the message is near the top of the screen.
  3. Dynamic context menu placement: Placed below the message bubble, or above the reaction bar if the message is near the bottom of the screen.
  4. Preserves timestamp: Keeps the timestamp visible adjacent to the bubble without shifting or distorting the bubble position.

Testing:

  • Verified in Android Studio: compilePlayDebugKotlin, compilePlayDebugJavaWithJavac, and testPlayDebugUnitTest all pass.
  • Tested long-pressing top, middle, and bottom messages; verified the message bubble stays anchored in place while the reaction bar and context menu appear around it.

@mpretty-cyro mpretty-cyro left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, I did some quick testing and it looks like there are a few bugs with the current code:

  • An outgoing message lands 8dp to the right of where it was (screenshot 1)
  • In RTL languages, the message moves sideways by the width of its timestamp (incoming messages can end up at or past the right edge) (screenshot 2 - with force RTL enabled)
  • The reaction bar can be covered by the context menu (screenshot 3)
  • When the menu closes the message slides in the wrong direction before snapping back to the original position (video 1)

screenshot 1
Screenshot 2026-11-18 at 6 48 34 am

screenshot 2
Screenshot 2026-11-18 at 7 04 00 am

screenshot 3
Screenshot 2026-11-18 at 7 02 55 am

video 1
https://github.com/user-attachments/assets/d5724c24-78e6-4676-8c6e-04697ec06b54

@igotlinux

Copy link
Copy Markdown
Contributor Author

Thanks for testing and catching those @mpretty-cyro! Fixed all 4 issues in the latest commit:

  • Accounted for both leftMargin and rightMargin (marginHorizontal) on conversationTimestamp so outgoing bubbles no longer land 8dp off.
  • Switched bubble/timestamp horizontal offset logic to use isMessageOnLeft (isOutgoing xor isLtr) so RTL incoming/outgoing messages stay anchored at their exact X position.
  • Clamped reaction bar bounds, allowed side-by-side placement in landscape regardless of vertical fit, and updated calculateMenuY so the context menu flips cleanly without covering the reaction bar.
  • Removed the X/Y/SCALE animators in newHideAnimators() that were sliding the bubble away on close before snapping back.

Verified with compilePlayDebugKotlin and testPlayDebugUnitTest.

@igotlinux

Copy link
Copy Markdown
Contributor Author

also noticed another bug when the keyboard is open and you long press the last sent/received message. hideKeyboard() was closing the keyboard after we already grabbed bubbleY, so the recyclerview would resize/drop down while the overlay snapshot stayed up at the old spot (causing a duplicate bubble sticking out underneath).

i kept the keyboard as-is when long pressing and added WindowInsetsCompat.Type.ime() to the overlay insets so the reaction bar and context menu stay above the keyboard instead. let me know if you want screenshots of what was happening before

@igotlinux

Copy link
Copy Markdown
Contributor Author

also clipped the overlay message snapshot to the recyclerview's visible bounds. before this, if a tall message was partially scrolled under the top app bar or behind the input bar, the unclipped bitmap would draw over them. now it stays strictly within the chat list area between the top bar and input bar/keyboard

@igotlinux

Copy link
Copy Markdown
Contributor Author

Any updates ?

@mpretty-cyro

Copy link
Copy Markdown
Collaborator

Any updates ?

I'll try to do some testing on this one today - there are a few more issues but if my testing goes ok I'll look to push up fixes before merging

The picture landed a timestamp's width beside the real message on the
long-press where the timestamp switched from shown to hidden: for
outgoing messages in LTR and incoming ones in RTL. In RTL it also moved
on the switch back.
The overlay's picture of a message taller than 2000px was drawn smaller
than the message, because the snapshot is capped at that size. Capturing
only the part inside the list keeps it small without scaling, so it is
drawn at full size and no longer needs clipping. The reaction bar and
menu are now placed around the part you can see.
Long-pressing a message near the top of the list opens the bar below it.
Sliding down onto an emoji without lifting selected nothing, because the
band a drag counts in only extended above the touch point.
Long-pressing a message with the keyboard open now closes the keyboard
and shows the overlay once the list has settled, so the picture lands
on the message. The keyboard isn't reopened afterwards.
With the keyboard open, the overlay waits for the keyboard to close and
then found the message's row by list position, so a message above it
coming or going in that time showed the neighbouring message while the
reactions and menu acted on the pressed one. The row is now found by
message id, and a request is dropped if the keyboard isn't reported
hidden within a second.
With the keyboard open the overlay waits for it to close, so a press
released just after the long-press fired could lift before the overlay
appeared. The overlay then took the next tap as the rest of the
long-press and ignored it: a tap on an emoji neither reacted nor
closed the overlay.
@mpretty-cyro

Copy link
Copy Markdown
Collaborator

@igotlinux I found a few more issues today during testing so I made the following changes before merging:

  • The four original commits are unchanged; the changes are seven commits on top.
  • The message picture stays on the message. When the timestamp was shown for one long-press and hidden for the next, the picture landed a timestamp's width beside the message: for outgoing messages in left-to-right layouts, incoming ones in right-to-left, and in right-to-left also on the switch back. The row is now pinned to the left and laid out again after the timestamp's visibility changes.
  • Only the visible part of the message is captured. The snapshot is capped at 2000 px, so a message taller than that was drawn smaller than the real one. The capture is now the part of the message inside the list, at full size, so the clip rectangle is gone, and the reaction bar and menu are placed around the part you can see.
  • Dragging onto the reaction bar works when it opens below the message, as it does for a message at the top of the list. The band a drag counted in only reached upwards from the touch point.
  • Long-pressing with the keyboard open closes the keyboard first, then shows the overlay once the list has settled, as iOS does. The keyboard isn't reopened afterwards. With the keyboard left open, typing still went to the composer under the overlay, and closing it moved the list out from under the picture.
    • The delayed overlay finds the message by id, so a message above it coming or going meanwhile can't swap it for a neighbour. A request is dropped if the keyboard isn't reported closed within a second.
    • A press released just after the long-press fired could lift before the overlay appeared, and the overlay then ignored the next tap. That tap is now handled as a new gesture.
  • Removed code the overlay no longer uses: LONG_PRESS_SCALE_FACTOR, getAvailableScreenHeight(), getAvailableScreenWidth(), statusBarHeight, duplicate scale resets, and SelectedConversationModel's focusedView, bubbleWidth and contentClipBounds.

@mpretty-cyro
mpretty-cyro merged commit 6ad82e6 into session-foundation:dev Nov 30, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants