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

Đang mở Phù hợp với người mới
#1,437 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@yashsarvaiya45 đang làm issue này rồi.

Từ ngày 17/11/2026.

  • #1438 của @yashsarvaiya45 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, react
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu với packages/react/src/views/Message/MessageToolbox.js, tập trung vào kiểm tra khả năng hiển thị, mảng dependency của options useMemo và ánh xạ surfaceOptions. Xác nhận các thao tác chỉnh sửa và sao chép cần hoạt động như thế nào đối với tin nhắn âm thanh và video, cũng như trạng thái đang chỉnh sửa được biểu diễn ra sao. Công việc hoàn tất khi ba vấn đề được báo cáo đã được khắc phục và các thao tác trên hộp công cụ được cập nhật chính xác khi quyền được tải.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
JavaScript
Star
170
Fork
397
Merge trung bình
8 ngày 20 giờ
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của RocketChat/EmbeddedChat

Tất cả issue của RocketChat/EmbeddedChat

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.