UiKit modal and contextual bar remount on every re-render, typed input is lost

Đang mở Phù hợp với người mới
#1,471 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

@Jaivansh-777 đang làm issue này rồi.

Từ ngày 28/11/2026.

  • #1472 của @Jaivansh-777 — đ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
82/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

Khóa lỗi nằm ở UiKitModal trong packages/react/src/views/ChatBody/ChatBody.js (khoảng dòng 440) và ở UiKitContextualBar trong packages/react/src/views/ChatLayout/ChatLayout.js (khoảng dòng 173). Hãy xác nhận rằng các đối tượng dữ liệu của view có id ổn định, sau đó thay Math.random() bằng id đó. Hoàn thành khi văn bản đã nhập trong modal hoặc thanh ngữ cảnh vẫn được giữ lại sau khi tin nhắn mới khiến phòng được render lại.

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

Mô tả

Description:

UiKitModal and UiKitContextualBar are rendered with a random key:

  • packages/react/src/views/ChatBody/ChatBody.js:440: <UiKitModal key={Math.random()} initialView={uiKitModalData} />
  • packages/react/src/views/ChatLayout/ChatLayout.js:173: <UiKitContextualBar key={Math.random()} ... />

Because the key changes on every render, React unmounts and remounts the surface whenever the parent re-renders (a new message arrives, the typing indicator updates, scroll state changes). Anything the user typed into an app's modal or contextual bar is lost and the surface state is reset.

Steps to reproduce:
  1. Install a Rocket.Chat app that opens a UIKit modal (or contextual bar) with a text input.
  2. Open it from EmbeddedChat and start typing in the input.
  3. While it is open, have another user send a message in the room (anything that re-renders ChatBody / ChatLayout).
  4. The modal remounts and the typed text is gone.
Expected behavior:

The modal / contextual bar keeps its state until the view itself changes.

Actual behavior:

The surface is remounted on every parent re-render and loses its input.

Suggested fix: use a stable key, the view id (key={uiKitModalData?.id} and key={uiKitContextualBarData?.id}). I'd be happy to open a PR for this.

Ngôn ngữ chính
JavaScript
Star
171
Fork
421
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
4

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.