@@ -415,6 +415,7 @@ export default {
415
415
filteredUsersTag: [],
416
416
selectedUsersTag: [],
417
417
textareaCursorPosition: null ,
418
+ cursorRangePosition: null ,
418
419
recorder: this .initRecorder (),
419
420
isRecording: false ,
420
421
format: ' mp3'
@@ -645,6 +646,7 @@ export default {
645
646
emoji +
646
647
this .message .substr (endPosition, this .message .length - 1 )
647
648
649
+ this .cursorRangePosition = position
648
650
this .focusTextarea ()
649
651
},
650
652
updateShowUsersTag (query ) {
@@ -670,6 +672,8 @@ export default {
670
672
671
673
this .selectedUsersTag = [... this .selectedUsersTag , { ... user }]
672
674
675
+ this .cursorRangePosition =
676
+ position + user .username .length + space .length + 1
673
677
this .focusTextarea ()
674
678
},
675
679
resetFooterList () {
@@ -735,6 +739,16 @@ export default {
735
739
if (detectMobile () && disableMobileFocus) return
736
740
if (! this .$refs [' roomTextarea' ]) return
737
741
this .$refs [' roomTextarea' ].focus ()
742
+
743
+ if (this .cursorRangePosition ) {
744
+ setTimeout (() => {
745
+ this .$refs [' roomTextarea' ].setSelectionRange (
746
+ this .cursorRangePosition ,
747
+ this .cursorRangePosition
748
+ )
749
+ this .cursorRangePosition = null
750
+ }, 0 )
751
+ }
738
752
},
739
753
preventKeyboardFromClosing () {
740
754
if (this .keepKeyboardOpen ) this .$refs [' roomTextarea' ].focus ()
0 commit comments