Skip to content

Commit 8aff008

Browse files
committed
(fix) select emoji removes previous substring
1 parent ded0197 commit 8aff008

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ChatWindow/Room/Room.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,11 @@ export default {
611611
this.resetFooterList()
612612
}
613613
},
614-
getCharPosition() {
614+
getCharPosition(tagChar) {
615615
const cursorPosition = this.$refs['roomTextarea'].selectionStart
616616
617617
let position = cursorPosition
618-
while (position > 0 && this.message.charAt(position - 1) !== '@') {
618+
while (position > 0 && this.message.charAt(position - 1) !== tagChar) {
619619
position--
620620
}
621621
@@ -638,7 +638,7 @@ export default {
638638
this.filteredEmojis = matchingKeys.map(key => this.emojisList[key])
639639
},
640640
selectEmoji(emoji) {
641-
const { position, endPosition } = this.getCharPosition()
641+
const { position, endPosition } = this.getCharPosition(':')
642642
643643
this.message =
644644
this.message.substr(0, position - 1) +
@@ -656,7 +656,7 @@ export default {
656656
).filter(user => user._id !== this.currentUserId)
657657
},
658658
selectUserTag(user) {
659-
const { position, endPosition } = this.getCharPosition()
659+
const { position, endPosition } = this.getCharPosition('@')
660660
661661
const space = this.message.substr(endPosition, endPosition).length
662662
? ''

0 commit comments

Comments
 (0)