Skip to content

Commit b7fef85

Browse files
authored
Merge pull request #190 from DevGajjar28/handleOutsideClick
Fix: Update handleOutsideClick to use textarea ref (#175)
2 parents 8549aee + a1249ca commit b7fef85

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

agentic_security/static/main.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,27 +110,26 @@ var app = new Vue({
110110
},
111111
focusTextarea() {
112112
this.isFocused = true;
113-
self = this.$refs;
113+
// Remove 'self' assignment if not used elsewhere
114114
this.$nextTick(() => {
115-
// Focus the textarea after rendering
116-
self.textarea.focus();
117-
this.adjustHeight({ target: self.textarea });
115+
this.$refs.textarea.focus();
116+
this.adjustHeight({ target: this.$refs.textarea });
118117
});
119-
document.addEventListener("mousedown", this.handleClickOutside);
120-
118+
// Correct the event listener to use handleOutsideClick
119+
document.addEventListener("mousedown", this.handleOutsideClick);
121120
},
122121
handleOutsideClick(event) {
123-
if (!this.$refs.container.contains(event.target)) {
122+
if (!this.$refs.textarea.contains(event.target)) {
124123
this.isFocused = false;
125-
document.removeEventListener("mousedown", this.handleClickOutside);
124+
document.removeEventListener("mousedown", this.handleOutsideClick);
126125
}
127126
},
128127
unfocusTextarea() {
129128
this.isFocused = false;
130129
},
131130
acceptConsent() {
132131
this.showConsentModal = false; // Close the modal
133-
132+
134133
try {
135134
localStorage.setItem('consentGiven', 'true'); // Save consent to local storage
136135
} catch (e) {
@@ -215,7 +214,7 @@ var app = new Vue({
215214
spec: this.modelSpec,
216215
};
217216
let startTime = performance.now(); // Capture start time
218-
217+
219218
try {
220219
const response = await fetch(`${SELF_URL}/verify`, {
221220
method: 'POST',
@@ -224,7 +223,7 @@ var app = new Vue({
224223
},
225224
body: JSON.stringify(payload),
226225
});
227-
226+
228227
let r = await response.json();
229228

230229
let endTime = performance.now(); // Capture end time

0 commit comments

Comments
 (0)