bug: Composer textarea doesn't resize when the SDK sets its text (paste, draft, clear after send)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 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時間
- マージ済み PR(30日)
- 106
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 件 ·
メンテナーはふだん 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 日以内に返信