diff --git a/src/widgets/send-message.jsx b/src/widgets/send-message.jsx index f5d5b0c2..aac712a6 100644 --- a/src/widgets/send-message.jsx +++ b/src/widgets/send-message.jsx @@ -228,9 +228,14 @@ class SendMessage extends React.PureComponent { } else if (prevProps.initMessage != this.props.initMessage) { const msg = this.props.initMessage || ''; this.setState({message: msg}, _ => { - // If there is text, scroll to bottom and set caret to the end. - this.messageEditArea.scrollTop = this.messageEditArea.scrollHeight; - this.messageEditArea.setSelectionRange(msg.length, msg.length); + // 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. + this.messageEditArea.scrollTop = this.messageEditArea.scrollHeight; + this.messageEditArea.setSelectionRange(msg.length, msg.length); + } }); } if (prevProps.reply != this.props.reply) {