bug: Composer textarea doesn't resize when the SDK sets its text (paste, draft, clear after send)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 62/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- react, typescript
- Domaine
- frontend
Piste de recherche
Start in TextareaComposer.tsx, where a useLayoutEffect writes textarea.value from the composer's text without notifying the autosize component. Reproduce by changing the text programmatically to a multi-line value and checking the textarea height, then compare with typing. Done means the height follows the text after paste, draft restore and clear-after-send, and a test covers one of these cases.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
TextareaComposer writes the composer's text into the textarea itself, in a useLayoutEffect:
if (textarea.value !== text) {
textarea.value = text;
}
react-textarea-autosize measures the textarea in its own layout effect, which runs first because it's a child, and again on onChange and window resize. A value written from outside doesn't trigger any of those. So when the text changes without the user typing, the textarea keeps its old height:
- Multi-line paste that goes through the composer's paste handling: it doesn't grow.
- A restored draft on opening a channel: it stays one row high.
- Clearing after sending a multi-line message: it stays tall.
It corrects itself on some later render, often a second or two later.
To Reproduce
- Type a message that wraps to four or five lines, and send it. The empty textarea stays four or five lines tall.
- Or: type a multi-line draft, switch to another channel and back. The restored draft shows in a one-row textarea.
Expected behavior
The textarea fits its text as soon as the text changes, however it changed.
Suggested fix
After writing textarea.value, trigger react-textarea-autosize's measurement. For example, re-render once after the write, or measure through a ref-exposed resize. We can open a PR with a test.
Our workaround
We wrap TextareaComposer and render it once more in a useLayoutEffect keyed on the composer's text. A parent's layout effect runs after the child's, so by then the SDK has written the value and the extra render re-measures it. We also had to opt this component out of the React Compiler ("use no memo"), or the compiler skips that render.
Package version
- stream-chat-react: 15.0.0.
TextareaComposer.tsxis unchanged in 15.0.2. - stream-chat-js: 10.0.1
Desktop
- Chrome on macOS
Additional context
App id: 67855
- Langage dominant
- TypeScript
- Étoiles
- 845
- Forks
- 295
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 106
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de GetStream/stream-chat-react
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
GetStream/stream-chat-react#3467 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 62/100
GetStream/stream-chat-react#3466 ·
Les mainteneurs répondent en général sous 1 jour
-
bug status: unconfirmed
Difficulté 4/5 3-5 jours Accessibilité débutants 42/100
GetStream/stream-chat-react#2647 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
dependencies
Difficulté 3/5 1-2 jours Accessibilité débutants 52/100
GetStream/stream-chat-react#1982 · 8 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de GetStream/stream-chat-react
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
vercel-labs/ui#1139 ·
Les mainteneurs répondent en général sous 1 jour
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10Peut-être pris @goranai l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
[Bug] IntegerRange.contains counts a non-integer just above max as inside an inclusive rangeOuvertebot:ai-assisted component:platform-js status:untriaged
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
midnightntwrk/platform-js#93 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 74/100
nicobailon/pi-web-access#710 ·
Les mainteneurs répondent en général sous 1 jour