Bug: Unused media visibility check and missing useMemo dependencies cause stale/invalid actions in MessageToolbox.js

Open Beginner friendly
#1,437 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@yashsarvaiya45 is already working on this.

Since Nov 17, 2026.

  • #1438 by @yashsarvaiya45 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, react
Domain
frontend

Research direction

Start with packages/react/src/views/Message/MessageToolbox.js, focusing on the visibility check, the options useMemo dependency array, and the surfaceOptions mapping. Confirm how the edit and copy actions should behave for audio and video messages and how active editing is represented. Done when the three reported issues are fixed and the toolbox actions update correctly as permissions load.

Written by the indexing model from the issue text.

Description

Description

In packages/react/src/views/Message/MessageToolbox.js, there are three bugs affecting message action visibility and state updates:

  1. Unused isVisibleForMessageType check & missing optional chaining: isVisibleForMessageType is computed on lines 93–95 to hide text-only actions (edit and copy) on audio/mpeg and video/mp4 messages, but it is never applied to options.edit.visible or options.copy.visible. Additionally, message.files?.[0].type lacks optional chaining on [0], which can throw a TypeError when message.files is an empty array [].
  2. Stale useMemo dependencies for role permissions: The options useMemo hook omits isAllowedToEditMessage, canDeleteMessage, isAllowedToReport, isVisibleForMessageType, and handleCopyMessageLink from its dependency array. When user roles and permissions load asynchronously, the memoized options object fails to recompute, leaving Edit, Delete, and Report actions hidden or stale.
  3. Dropped color and ghost props in surfaceOptions: options.edit defines color and ghost properties to highlight active editing state (isEditing), but surfaceOptions omits these properties when mapping items for SurfaceMenu.
Affected File
  • packages/react/src/views/Message/MessageToolbox.js (lines 93–218)
Expected Behavior
  • Apply isVisibleForMessageType (with safe optional chaining message.files?.[0]?.type) to edit and copy visibility.
  • Include all permission flags and handlers in the options useMemo dependency array so toolbox actions update when roles resolve.
  • Forward color and ghost properties in surfaceOptions.
Dominant language
JavaScript
Stars
171
Forks
421
Avg merge
3d 6h
Merged PRs (30d)
4

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RocketChat/EmbeddedChat

All issues in RocketChat/EmbeddedChat

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.