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

オープン 初心者向け
#1,471 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Jaivansh-777 がすでに取り組んでいます。

2026年11月28日 から。

  • #1472 @Jaivansh-777 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, react
領域
frontend

調査の方向性

問題のキーは packages/react/src/views/ChatBody/ChatBody.js の UiKitModal(440行目付近)と、packages/react/src/views/ChatLayout/ChatLayout.js の UiKitContextualBar(173行目付近)にあります。ビューのデータオブジェクトが安定した id を持っていることを確認し、Math.random() をその id に置き換えてください。モーダルまたはコンテキストバーに入力したテキストが、新しいメッセージによってルームが再レンダリングされた後も保持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
JavaScript
スター
171
フォーク
421
平均マージ
3日 6時間
マージ済み PR(30日)
4

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RocketChat/EmbeddedChat のほかの issue

RocketChat/EmbeddedChat の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。