bug: Composer textarea doesn't resize when the SDK sets its text (paste, draft, clear after send)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 62/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- react, typescript
- 領域
- frontend
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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
- 主要語言
- TypeScript
- 星號
- 845
- 分支
- 295
- 平均合併
- 1 天 8 小時
- 30 天內合併 PR
- 106
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
GetStream/stream-chat-react 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
GetStream/stream-chat-react#3467 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 62/100
GetStream/stream-chat-react#3466 ·
維護者通常 1 天內回覆
-
bug status: unconfirmed
難度 4/5 3-5 天 新手友好度 42/100
GetStream/stream-chat-react#2647 · 2 則留言 ·
維護者通常 1 天內回覆
-
dependencies
難度 3/5 1-2 天 新手友好度 52/100
GetStream/stream-chat-react#1982 · 8 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
查看 GetStream/stream-chat-react 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
vercel-labs/ui#1139 ·
維護者通常 1 天內回覆
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10可能已有人在做 @goranai 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
bot:ai-assisted component:platform-js status:untriaged
難度 2/5 1-3 小時 新手友好度 82/100
midnightntwrk/platform-js#93 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
-
難度 1/5 1 小時以內 新手友好度 74/100
nicobailon/pi-web-access#710 ·
維護者通常 1 天內回覆