about summary refs log tree commit diff
path: root/src/view/com/composer/text-input/TextInput.tsx
diff options
context:
space:
mode:
authorjim <310223+jimmylee@users.noreply.github.com>2025-07-24 17:18:40 -0700
committerGitHub <noreply@github.com>2025-07-24 17:18:40 -0700
commit26755445e375211e7b223fa86393813d68f93abc (patch)
tree7dcc2f95fd3cfbf1d45767bdfda1561bdc3bb84c /src/view/com/composer/text-input/TextInput.tsx
parent101b3262b88b494459a211bdc697b1fd3222a50c (diff)
parentead6862fc64597fdf811e0fb88e12ef0409b8d11 (diff)
downloadvoidsky-26755445e375211e7b223fa86393813d68f93abc.tar.zst
Merge pull request #8714 from internet-development/c/app-1332-handle-autocomplete-broken-for-handles-with-hyphens
Fix some auto complete issues on mobile
Diffstat (limited to 'src/view/com/composer/text-input/TextInput.tsx')
-rw-r--r--src/view/com/composer/text-input/TextInput.tsx9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/view/com/composer/text-input/TextInput.tsx b/src/view/com/composer/text-input/TextInput.tsx
index e9c5d86b9..ea92d0b91 100644
--- a/src/view/com/composer/text-input/TextInput.tsx
+++ b/src/view/com/composer/text-input/TextInput.tsx
@@ -96,10 +96,11 @@ export const TextInput = forwardRef(function TextInputImpl(
       newRt.detectFacetsWithoutResolution()
       setRichText(newRt)
 
-      const prefix = getMentionAt(
-        newText,
-        textInputSelection.current?.start || 0,
-      )
+      // NOTE: BinaryFiddler
+      // onChangeText happens before onSelectionChange, cursorPos is out of bound if the user deletes characters,
+      const cursorPos = textInputSelection.current?.start ?? 0
+      const prefix = getMentionAt(newText, Math.min(cursorPos, newText.length))
+
       if (prefix) {
         setAutocompletePrefix(prefix.value)
       } else if (autocompletePrefix) {