fix: "Jump to message" not navigating to cross-room messages

Merged
RI
3mo ago
+147-9

Proposed changes (including videos or screenshots)

"Jump to message" does nothing when the message belongs to another room, which is the usual case for global search results.

The action only writes ?msg=<id> onto the current room's URL. Until 8.5.0 RoomBody mounted useLoadSurroundingMessages, which called goToRoom(message.rid) for messages in another room. #40105 removed that call site and replaced the jump logic with useTryToJumpToMessage, which only looks inside the currently open room's message list, so a cross-room hit resolves to nothing.

useTryToJumpToMessage now calls goToRoom(message.rid) when the message belongs to another room. useGoToRoom forwards the current search parameters, so msg survives the navigation and the destination room's own instance of the hook finishes the jump.

Thread messages are excluded because useTryToJumpToThreadMessage already navigates those with the correct tab: 'thread' overrides.

Issue(s)

Steps to test or reproduce

  1. Enable Admin → Settings → Search → Global Search.
  2. Post a message in channel A, then open channel B.
  3. Open ⋮ → Search Messages, turn on Global search, and search for the text from channel A.
  4. Click Jump to message.

Before: stays in channel B, URL just gains ?msg=<id>. After: navigates to channel A and highlights the message.

Also check same-room results, pinned/starred messages and thread messages still jump correctly.

Further comments

Summary by CodeRabbit

  • Bug Fixes

    • Fixed “Jump to message” so selecting a message from another room opens the correct room and message.
    • Preserved in-place navigation for messages in the current room.
    • Ensured thread messages continue to use the appropriate navigation behavior.
    • Improved navigation reliability when opening messages from global search.
  • Tests

    • Added coverage for cross-room, same-room, and thread message navigation.
    • Added end-to-end coverage for jumping to messages from global search.