Fix: Update handleOutsideClick to use textarea ref (#175)

This commit is contained in:
Dev Gajjar
2025-03-18 16:12:12 +05:30
parent 8549aee952
commit a1249cae12
+7 -8
View File
@@ -110,19 +110,18 @@ var app = new Vue({
}, },
focusTextarea() { focusTextarea() {
this.isFocused = true; this.isFocused = true;
self = this.$refs; // Remove 'self' assignment if not used elsewhere
this.$nextTick(() => { this.$nextTick(() => {
// Focus the textarea after rendering this.$refs.textarea.focus();
self.textarea.focus(); this.adjustHeight({ target: this.$refs.textarea });
this.adjustHeight({ target: self.textarea });
}); });
document.addEventListener("mousedown", this.handleClickOutside); // Correct the event listener to use handleOutsideClick
document.addEventListener("mousedown", this.handleOutsideClick);
}, },
handleOutsideClick(event) { handleOutsideClick(event) {
if (!this.$refs.container.contains(event.target)) { if (!this.$refs.textarea.contains(event.target)) {
this.isFocused = false; this.isFocused = false;
document.removeEventListener("mousedown", this.handleClickOutside); document.removeEventListener("mousedown", this.handleOutsideClick);
} }
}, },
unfocusTextarea() { unfocusTextarea() {