fix: safer access to textarea

This commit is contained in:
Shivam Mishra
2023-09-20 12:51:00 +05:30
parent adf67b79ce
commit 47921bca3d
@@ -113,7 +113,6 @@ export default {
});
},
setCursor() {
const textarea = this.$refs.textarea;
const bodyWithoutSignature = removeSignature(
this.value,
this.cleanedSignature
@@ -121,9 +120,12 @@ export default {
// only trim at end, so if there are spaces at the start, those are not removed
const bodyEndsAt = bodyWithoutSignature.trimEnd().length;
const textarea = this.$refs.textarea;
textarea.focus();
textarea.setSelectionRange(bodyEndsAt, bodyEndsAt);
if (textarea) {
textarea.focus();
textarea.setSelectionRange(bodyEndsAt, bodyEndsAt);
}
},
onInput(event) {
this.$emit('input', event.target.value);