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

Aperta Adatta ai principianti
#1,471 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Jaivansh-777 ci sta già lavorando.

Dal 28/11/2026.

  • #1472 di @Jaivansh-777 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, react
Ambito
frontend

Direzione di ricerca

La chiave errata è su UiKitModal in packages/react/src/views/ChatBody/ChatBody.js (intorno alla riga 440) e su UiKitContextualBar in packages/react/src/views/ChatLayout/ChatLayout.js (intorno alla riga 173). Verifica che gli oggetti dati della vista contengano un id stabile, quindi sostituisci Math.random() con quell'id. Completato quando il testo digitato in un modale o in una barra contestuale sopravvive al nuovo rendering della stanza causato da un nuovo messaggio.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
171
Fork
421
Merge medio
3g 6h
PR unite (30g)
4

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di RocketChat/EmbeddedChat

Tutte le issue di RocketChat/EmbeddedChat

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.