From 9f72268df7c72f79e0e4983700a6dd5e640d2efa Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 21 Aug 2019 16:40:35 +0200 Subject: [PATCH] avoid null-refs when receiving an action before initial rendering --- src/components/views/rooms/SendMessageComposer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/SendMessageComposer.js b/src/components/views/rooms/SendMessageComposer.js index 0d1d24c282..4137de54c5 100644 --- a/src/components/views/rooms/SendMessageComposer.js +++ b/src/components/views/rooms/SendMessageComposer.js @@ -240,7 +240,7 @@ export default class SendMessageComposer extends React.Component { switch (payload.action) { case 'reply_to_event': case 'focus_composer': - this._editorRef.focus(); + this._editorRef && this._editorRef.focus(); break; case 'insert_mention': this._insertMention(payload.user_id); @@ -258,7 +258,7 @@ export default class SendMessageComposer extends React.Component { const userPillPart = this.model.partCreator.userPill(displayName, userId); this.model.insertPartsAt([userPillPart], this._editorRef.getCaret()); // refocus on composer, as we just clicked "Mention" - this._editorRef.focus(); + this._editorRef && this._editorRef.focus(); } _insertQuotedMessage(event) { @@ -269,7 +269,7 @@ export default class SendMessageComposer extends React.Component { quoteParts.push(partCreator.newline()); this.model.insertPartsAt(quoteParts, {offset: 0}); // refocus on composer, as we just clicked "Quote" - this._editorRef.focus(); + this._editorRef && this._editorRef.focus(); } render() {