Commit ·
5353bc3
1
Parent(s): bf57d15
fix(autocomplete): only trigger after space - no partial words
Browse files- src/js/autocomplete.js +10 -1
src/js/autocomplete.js
CHANGED
|
@@ -153,7 +153,16 @@
|
|
| 153 |
return;
|
| 154 |
}
|
| 155 |
|
| 156 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
var trimmed = context.trimEnd();
|
| 158 |
if (!trimmed || trimmed.length < MIN_CONTEXT_LEN) {
|
| 159 |
dismiss();
|
|
|
|
| 153 |
return;
|
| 154 |
}
|
| 155 |
|
| 156 |
+
// CRITICAL: Only trigger when the user just typed a SPACE
|
| 157 |
+
// (meaning they finished a word). Partial words like "عا" produce garbage.
|
| 158 |
+
var lastChar = context[context.length - 1];
|
| 159 |
+
if (lastChar !== ' ' && lastChar !== '\u00A0') {
|
| 160 |
+
// User is still typing a word — don't send partial word to backend
|
| 161 |
+
dismiss();
|
| 162 |
+
return;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
// Trim trailing spaces for the API call (backend expects clean context)
|
| 166 |
var trimmed = context.trimEnd();
|
| 167 |
if (!trimmed || trimmed.length < MIN_CONTEXT_LEN) {
|
| 168 |
dismiss();
|