From 97c7f3753bf86cce373d5cb3624f488c329f39b0 Mon Sep 17 00:00:00 2001 From: Panagiotis <27917356+panoschal@users.noreply.github.com> Date: Thu, 25 Mar 2021 20:58:39 +0200 Subject: [PATCH] fix: save editor state when reply is open --- src/components/views/rooms/SendMessageComposer.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/SendMessageComposer.js b/src/components/views/rooms/SendMessageComposer.js index 51899a0e45..aca2066d34 100644 --- a/src/components/views/rooms/SendMessageComposer.js +++ b/src/components/views/rooms/SendMessageComposer.js @@ -472,12 +472,17 @@ export default class SendMessageComposer extends React.Component { } } + // should save state when editor has contents or reply is open + _shouldSaveStoredEditorState = () => { + return !this.model.isEmpty || this.props.replyToEvent; + } + _saveStoredEditorState = () => { - if (this.model.isEmpty) { - this._clearStoredEditorState(); - } else { + if (this._shouldSaveStoredEditorState()) { const item = SendHistoryManager.createItem(this.model, this.props.replyToEvent); localStorage.setItem(this._editorStateKey, JSON.stringify(item)); + } else { + this._clearStoredEditorState(); } }