From 414908611d5d688488e2c9c8d9e23e483a217725 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 17 Jul 2018 13:48:15 +0100 Subject: [PATCH] prevent exception if there is no text node at anchor Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/MessageComposerInput.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index 841fcccf06..e4bd21cdf0 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -382,7 +382,8 @@ export default class MessageComposerInput extends React.Component { const quote = Block.create('block-quote'); if (this.state.isRichTextEnabled) { let change = editorState.change(); - if (editorState.anchorText.text === '' && editorState.anchorBlock.nodes.size === 1) { + const anchorText = editorState.anchorText; + if ((!anchorText || anchorText.text === '') && editorState.anchorBlock.nodes.size === 1) { // replace the current block rather than split the block change = change.replaceNodeByKey(editorState.anchorBlock.key, quote); }