diff --git a/src/components/NewMessage/NewMessage.vue b/src/components/NewMessage/NewMessage.vue index eba7e11d232..dcf06b0ced1 100644 --- a/src/components/NewMessage/NewMessage.vue +++ b/src/components/NewMessage/NewMessage.vue @@ -205,7 +205,12 @@ import { useGroupwareStore } from '../../stores/groupware.ts' import { useSettingsStore } from '../../stores/settings.js' import { fetchClipboardContent } from '../../utils/clipboard.js' import { ONE_DAY_IN_MS } from '../../utils/formattedTime.ts' -import { getCurrentSelectionRange, insertTextInElement, selectRange } from '../../utils/selectionRange.ts' +import { + getCurrentSelectionRange, + getRangeAtEnd, + insertTextInElement, + selectRange, +} from '../../utils/selectionRange.ts' import { parseSpecialSymbols } from '../../utils/textParse.ts' export default { @@ -842,7 +847,8 @@ export default { }, restoreSelectionRange() { - selectRange(this.preservedSelectionRange, this.getContenteditable()) + // If nothing to restore, set cursor at the end + selectRange(this.preservedSelectionRange ?? getRangeAtEnd(this.getContenteditable()), this.getContenteditable()) this.preservedSelectionRange = null },