Rocket.Chat.Electron icon indicating copy to clipboard operation
Rocket.Chat.Electron copied to clipboard

Message list does not scroll to bottom when sending a custom emoji as the only content (Desktop app only, works in browser)

Open bababuilmao-sketch opened this issue 2 months ago • 11 comments

Search before asking

  • [x] I had searched in the issues and found no similar issues.

Operating System

  • [ ] macOS
  • [x] Windows
  • [ ] Linux

Operating System Version

Windows 11

It happens on the web browser too?

No, it just happens on the Desktop app

Rocket.Chat Desktop App Version

4.17.1

Rocket.Chat Server Version

8.8.1

Describe the bug

Description

When sending a message that contains only a custom emoji and no text, the message list does not scroll down to the new message. The behaviour is intermittent: sometimes it scrolls on the 4th emoji sent in a row, sometimes on the 5th.

The same server, same user and same custom CSS work correctly in a normal browser, so this appears to be specific to the desktop app rather than to the server version.

Actual behaviour

The list stays where it is and the new message is below the visible area. Clicking the jump-to-bottom control works as expected.

What I already ruled out

  • Plain text messages: always scroll correctly.
  • Custom emoji followed by text in the same message: scrolls correctly. Only an emoji on its own is affected.
  • GIFs sent through the Giphy integration: scroll correctly. These are rendered as attachments rather than inline, which may be relevant.
  • Custom CSS: cleared completely, behaviour unchanged.
  • Emoji size: tested with the default size, with a much larger size, and with .rcx-message__emoji--big set to exactly the same height as the inline variant. Behaviour unchanged in all three cases, so the height difference of the emoji-only rendering does not appear to be the cause.
  • Same account, same server, same channel in a normal browser: works correctly.

Server setup information

  • Version of Rocket.Chat Server: 8.8.1
  • Deployment method: docker (docker compose)
  • Number of running instances: 1
  • DB replicaset oplog: enabled
  • MongoDB version: 8.0.32
  • Host OS: Windows, Docker Desktop
  • Number of users: under 10

Client setup information

  • Desktop app version: [HIER DEINE VERSION EINTRAGEN, siehe Help > About]
  • Operating system: Windows
  • Browser used for the working comparison: [HIER DEIN BROWSER UND VERSION EINTRAGEN]

Additional context

Rocket.Chat 8 migrated the main message list to a virtualized implementation (PR #40105 in the main repository, using the Virtua library). Since the same server behaves correctly in an up-to-date browser but not in the desktop app, the bundled Chromium version in the app may be reporting resize events differently than a current browser does.

How to Reproduce

Steps to reproduce

  1. Upload an animated custom emoji (GIF) via Administration > Custom Emoji.
  2. Open a channel in the desktop app and scroll to the bottom.
  3. Send the custom emoji on its own, with no other text, several times in a row.
  4. Observe that the list stops following the newest message after a few sends.

Describe your Expected behavior

Expected behaviour

The message list scrolls to the bottom after sending, as it does for text messages.

Anything else

No response

Are you willing to submit a code contribution?

  • [ ] Yes, I am willing to submit a Pull Request!

bababuilmao-sketch avatar Sep 16 '26 17:09 bababuilmao-sketch

Hi @bababuilmao-sketch , I’d like to work on this issue. I’ll look into the scrolling problem with custom emoji messages and try to find the cause and fix it. Thank you !

iamshravanijadhav avatar Sep 23 '26 12:09 iamshravanijadhav

Hi @iamshravanijadhav I'm interested in contributing to this issue. I noticed your earlier comment and wanted to check whether you've started investigating it. If you haven't started or need any help, I'd be happy to look into the issue and work on a fix. Thanks!

Rahul2245 avatar Oct 09 '26 13:10 Rahul2245

Hi @Rahul2245 , yes, I’ve started working on it. I’ve investigated a possible cause and have almost got the issue fixed. I’m checking things further to make sure the fix works as expected. If I need any help, I’ll reach out. Thanks..

iamshravanijadhav avatar Oct 09 '26 14:10 iamshravanijadhav

Ok @iamshravanijadhav , Thanks for your response, I would like to know that do you have been assigned for this or working on yourself and making pull request

Rahul2245 avatar Oct 09 '26 14:10 Rahul2245

Actually I am working independently on it

iamshravanijadhav avatar Oct 09 '26 14:10 iamshravanijadhav

Thank you very much @iamshravanijadhav for your immediate response😊

Rahul2245 avatar Oct 09 '26 14:10 Rahul2245

Hi @iamshravanijadhav, any news on this? It has been about five weeks since you mentioned you almost had a fix. If you ran into something tricky, that is completely understandable, this one sits deep in the virtualized message list.

Since nobody is officially assigned here and there is no linked PR yet, @Rahul2245 should feel free to take a look as well if he is still interested. Happy to test any build on my side, I can reproduce the issue reliably.

bababuilmao-sketch avatar Nov 13 '26 07:11 bababuilmao-sketch

Hi @bababuilmao-sketch,

I've investigated the root cause and submitted a fix with full test coverage in PR #3673.

What was happening under the hood

Unlike plain text messages (which lay out immediate font line boxes) or Giphy attachments (which supply pre-calculated dimensions in metadata), a standalone custom emoji (<img>) has no accompanying text nodes and no definite dimensions prior to asset download.

In Rocket.Chat 8.x's virtualized list (inokawa/virtua), the message is initially placed and pinned while the emoji element has collapsed intrinsic dimensions. When the image asset finishes loading, the layout expands asynchronously. In Electron's <webview>, this post-mount expansion increases scrollHeight without triggering an automatic scroll offset adjustment. After 3–5 sends, the accumulated drift exceeds the virtual list's bottom threshold (10px), leading Virtua to infer that the user has scrolled up into history—which permanently drops bottom auto-scrolling for subsequent messages until manually jumped.

The Fix in #3673

  1. Definite Sizing & Containment: Injected scoped preload styling providing definite box sizing (1.5em for inline, 2.75em for big standalone emojis) with contain: size layout;, aspect-ratio: 1 / 1, and object-fit: contain so the layout engine reserves the exact rendered box upfront before image bytes resolve.
  2. User-Gated Bottom-Following State: In src/ui/preload/messageScroll.ts, a listener tracks bottom-following state and distinguishes genuine user navigation (wheel, touchmove, pointerdown, keydown) from layout-induced programmatic scroll events. Layout expansions cannot detach bottom following.
  3. Scroll Re-Pinning Guard: When an emoji loads while following the bottom, the container's bottom alignment is re-asserted immediately, while preserving the user's reading position if they have scrolled up into history.

Unit tests (src/ui/preload/__tests__/messageScroll.spec.ts) cover the user-vs-programmatic scroll gating, post-load expansions (>80px), and history preservation.

Feel free to check out PR #3673 or test the branch if you'd like to verify on your end!

jhaabhijeet864 avatar Nov 13 '26 18:11 jhaabhijeet864

Thanks a lot for digging into this, the explanation matches what I observed (it consistently broke after 3-5 sends).

Two notes from my side:

  1. In my setup (server 8.8.1) a standalone custom emoji rendered as an element with a background-image on .rcx-message__emoji--big, not as an . Worth checking whether both paths are covered.

  2. The fix hardcodes 1.5em / 2.75em, which are the defaults. I run custom CSS that overrides these to 3.5rem / 4rem, and larger emojis made the drift worse. Would the containment still hold if an admin changes the size via custom CSS?

I can reproduce reliably, so happy to test a build if one is available.

Abhijeet Jha @.***> schrieb am Fr., 13. Nov. 2026, 19:33:

jhaabhijeet864 left a comment (RocketChat/Rocket.Chat.Electron#3503) https://github.com/RocketChat/Rocket.Chat.Electron/issues/3503#issuecomment-6861633454

Hi @bababuilmao-sketch https://github.com/bababuilmao-sketch,

I've investigated the root cause and submitted a fix with full test coverage in PR #3673 https://github.com/RocketChat/Rocket.Chat.Electron/pull/3673. What was happening under the hood

Unlike plain text messages (which lay out immediate font line boxes) or Giphy attachments (which supply pre-calculated dimensions in metadata), a standalone custom emoji () has no accompanying text nodes and no definite dimensions prior to asset download.

In Rocket.Chat 8.x's virtualized list (inokawa/virtua), the message is initially placed and pinned while the emoji element has collapsed intrinsic dimensions. When the image asset finishes loading, the layout expands asynchronously. In Electron's , this post-mount expansion increases scrollHeight without triggering an automatic scroll offset adjustment. After 3–5 sends, the accumulated drift exceeds the virtual list's bottom threshold (10px), leading Virtua to infer that the user has scrolled up into history—which permanently drops bottom auto-scrolling for subsequent messages until manually jumped. The Fix in #3673 https://github.com/RocketChat/Rocket.Chat.Electron/pull/3673

  1. Definite Sizing & Containment: Injected scoped preload styling providing definite box sizing (1.5em for inline, 2.75em for big standalone emojis) with contain: size layout;, aspect-ratio: 1 / 1, and object-fit: contain so the layout engine reserves the exact rendered box upfront before image bytes resolve.
  2. User-Gated Bottom-Following State: In src/ui/preload/messageScroll.ts, a listener tracks bottom-following state and distinguishes genuine user navigation (wheel, touchmove, pointerdown, keydown) from layout-induced programmatic scroll events. Layout expansions cannot detach bottom following.
  3. Scroll Re-Pinning Guard: When an emoji loads while following the bottom, the container's bottom alignment is re-asserted immediately, while preserving the user's reading position if they have scrolled up into history.

Unit tests (src/ui/preload/tests/messageScroll.spec.ts) cover the user-vs-programmatic scroll gating, post-load expansions (>80px), and history preservation.

Feel free to check out PR #3673 https://github.com/RocketChat/Rocket.Chat.Electron/pull/3673 or test the branch if you'd like to verify on your end!

— Reply to this email directly, view it on GitHub https://github.com/RocketChat/Rocket.Chat.Electron/issues/3503?email_source=notifications&email_token=B27FVBI7HIR65IWOP5H5FEL5Y5HWNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMOBWGE3DGMZUGU2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6861633454, or unsubscribe https://github.com/notifications/unsubscribe-auth/B27FVBJ5AC62JWJYWOOLYRD5Y5HWNAVCNFSNUABEKJSXA33TNF2G64TZHMZTQNZWG42TMMZ3JFZXG5LFHM2TINZXHE3DGMJYGSQXMAQ . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS https://github.com/notifications/mobile/ios/B27FVBN6HIZ5R7QJWZ67KSL5Y5HWNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMOBWGE3DGMZUGU2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y and Android https://github.com/notifications/mobile/android/B27FVBL5OPU3TZ3CZR3NJVD5Y5HWNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMOBWGE3DGMZUGU2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI. Download it today! You are receiving this because you were mentioned.Message ID: @.***>

bababuilmao-sketch avatar Nov 13 '26 22:11 bababuilmao-sketch

Hi @bababuilmao-sketch,

Great catches! Both of those are very insightful edge cases that sit right at the boundary between Virtua’s item measurement cache and Electron’s layout pipeline:

  1. background-image vs <img> rendering: You are completely right—DOM load events only fire on <img> elements. For <span>/<div> elements styled with background-image, no load event is dispatched when the asset bytes resolve. To ensure both paths are covered, we've integrated a scoped ResizeObserver observing message elements (.rcx-message, .rcx-message__emoji--big). Whether rendered via <img> or background-image, any layout geometry change directly triggers bottom re-pinning as long as the user is actively following the bottom.

  2. Custom CSS Overrides (3.5rem / 4rem) & Containment: To ensure admin custom CSS always takes precedence effortlessly:

    • All default sizing rules are now wrapped in CSS :where(...) pseudo-classes (specificity (0, 0, 0)). Any custom CSS rule (e.g. .rcx-message__emoji--big { width: 3.5rem; height: 4rem; } with specificity (0, 1, 0)) automatically overrides the defaults with zero friction and without needing !important.
    • When larger dimensions (like 4rem) cause higher layout deltas (e.g. 50–60px), the ResizeObserver re-pinning handler seamlessly catches the delta and keeps scrollTop locked to scrollHeight - clientHeight, preventing the drift that previously detached Virtua on send #1 or #2.

I've pushed these enhancements to PR #3673 with accompanying unit tests. If you're able to test the branch with your custom CSS and server setup, we'd love to hear how it performs!

jhaabhijeet864 avatar Nov 14 '26 06:11 jhaabhijeet864

Thanks for the quick turnaround, both fixes sound right for my case. I'm not set up to build from source, so I'll wait for a released version and report back if anything is still off. Happy to confirm once it ships.

Abhijeet Jha @.***> schrieb am Sa., 14. Nov. 2026, 07:14:

jhaabhijeet864 left a comment (RocketChat/Rocket.Chat.Electron#3503) https://github.com/RocketChat/Rocket.Chat.Electron/issues/3503#issuecomment-6872941564

Hi @bababuilmao-sketch https://github.com/bababuilmao-sketch,

Great catches! Both of those are very insightful edge cases that sit right at the boundary between Virtua’s item measurement cache and Electron’s layout pipeline:

1.

background-image vs rendering: You are completely right—DOM load events only fire on elements. For /

elements styled with background-image, no load event is dispatched when the asset bytes resolve. To ensure both paths are covered, we've integrated a scoped ResizeObserver observing message elements (.rcx-message, .rcx-message__emoji--big). Whether rendered via or background-image, any layout geometry change directly triggers bottom re-pinning as long as the user is actively following the bottom. 2.

Custom CSS Overrides (3.5rem / 4rem) & Containment: To ensure admin custom CSS always takes precedence effortlessly:

  • All default sizing rules are now wrapped in CSS :where(...) pseudo-classes (specificity (0, 0, 0)). Any custom CSS rule (e.g. .rcx-message__emoji--big { width: 3.5rem; height: 4rem; } with specificity (0, 1, 0)) automatically overrides the defaults with zero friction and without needing !important.

I've pushed these enhancements to PR #3673 https://github.com/RocketChat/Rocket.Chat.Electron/pull/3673 with accompanying unit tests. If you're able to test the branch with your custom CSS and server setup, we'd love to hear how it performs!

— Reply to this email directly, view it on GitHub https://github.com/RocketChat/Rocket.Chat.Electron/issues/3503?email_source=notifications&email_token=B27FVBIX7NIRTXRL4SSUK5L5Y7Z4RA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMOBXGI4TIMJVGY2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6872941564, or unsubscribe https://github.com/notifications/unsubscribe-auth/B27FVBNSYSQJKKULB2UCCOD5Y7Z4RAVCNFSNUABEKJSXA33TNF2G64TZHMZTQNZWG42TMMZ3JFZXG5LFHM2TINZXHE3DGMJYGSQXMAQ . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS https://github.com/notifications/mobile/ios/B27FVBMLS6UQDYXXOZKIKAD5Y7Z4RA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMOBXGI4TIMJVGY2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y and Android https://github.com/notifications/mobile/android/B27FVBK3TJ43NQUXUM3OPX35Y7Z4RA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMOBXGI4TIMJVGY2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI. Download it today! You are receiving this because you were mentioned.Message ID: @.***>

bababuilmao-sketch avatar Nov 14 '26 10:11 bababuilmao-sketch