修复转发/切换话题时应用整体白屏崩溃
componentDidUpdate 的 initMessage 分支直接访问 this.messageEditArea 未判空,而输入框在 noInput(转发中)或 disabled(ACS未解析完)时会 被卸载——此时 initMessage(草稿/编辑内容)一变化就会解引用 null, 无 error boundary 兜底,整个应用白屏。 第十轮最小粒度测试 Ch3-4(实测复现2次)与 Ch8(同一处代码路径独立 命中)各自发现同一个bug。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
35f659249e
commit
9d2db5a648
@@ -228,9 +228,14 @@ class SendMessage extends React.PureComponent {
|
|||||||
} else if (prevProps.initMessage != this.props.initMessage) {
|
} else if (prevProps.initMessage != this.props.initMessage) {
|
||||||
const msg = this.props.initMessage || '';
|
const msg = this.props.initMessage || '';
|
||||||
this.setState({message: msg}, _ => {
|
this.setState({message: msg}, _ => {
|
||||||
|
// messageEditArea can be null here: initMessage (draft/edit content) can change while the
|
||||||
|
// textarea itself is unmounted, e.g. noInput during an active forward, or disabled while
|
||||||
|
// ACS is still resolving right after a topic switch.
|
||||||
|
if (this.messageEditArea) {
|
||||||
// If there is text, scroll to bottom and set caret to the end.
|
// If there is text, scroll to bottom and set caret to the end.
|
||||||
this.messageEditArea.scrollTop = this.messageEditArea.scrollHeight;
|
this.messageEditArea.scrollTop = this.messageEditArea.scrollHeight;
|
||||||
this.messageEditArea.setSelectionRange(msg.length, msg.length);
|
this.messageEditArea.setSelectionRange(msg.length, msg.length);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (prevProps.reply != this.props.reply) {
|
if (prevProps.reply != this.props.reply) {
|
||||||
|
|||||||
Reference in New Issue
Block a user