diff --git a/js/src/forum/components/TextEditor.js b/js/src/forum/components/TextEditor.js index c30ca4d20..fbf424b8d 100644 --- a/js/src/forum/components/TextEditor.js +++ b/js/src/forum/components/TextEditor.js @@ -122,6 +122,8 @@ export default class TextEditor extends Component { setSelectionRange(start, end) { const $textarea = this.$('textarea'); + if (!$textarea.length) return; + $textarea[0].setSelectionRange(start, end); $textarea.focus(); } @@ -134,6 +136,8 @@ export default class TextEditor extends Component { getSelectionRange() { const $textarea = this.$('textarea'); + if (!$textarea.length) return [0, 0]; + return [$textarea[0].selectionStart, $textarea[0].selectionEnd]; }