@@ -481,7 +481,7 @@ export default {
481
481
482
482
watch: {
483
483
message (val ) {
484
- this .$refs . roomTextarea .value = val
484
+ this .getTextareaRef () .value = val
485
485
},
486
486
loadingMessages (val ) {
487
487
if (val) {
@@ -539,7 +539,7 @@ export default {
539
539
this .newMessages = []
540
540
const isMobile = detectMobile ()
541
541
542
- this .$refs . roomTextarea .addEventListener (
542
+ this .getTextareaRef () .addEventListener (
543
543
' keyup' ,
544
544
debounce (e => {
545
545
if (e .key === ' Enter' && ! e .shiftKey && ! this .fileDialog ) {
@@ -564,15 +564,15 @@ export default {
564
564
50
565
565
)
566
566
567
- this .$refs . roomTextarea .addEventListener (' click' , () => {
567
+ this .getTextareaRef () .addEventListener (' click' , () => {
568
568
if (isMobile) this .keepKeyboardOpen = true
569
569
570
570
this .updateFooterList (' @' )
571
571
this .updateFooterList (' :' )
572
572
this .updateFooterList (' /' )
573
573
})
574
574
575
- this .$refs . roomTextarea .addEventListener (' blur' , () => {
575
+ this .getTextareaRef () .addEventListener (' blur' , () => {
576
576
this .resetFooterList ()
577
577
if (isMobile) setTimeout (() => (this .keepKeyboardOpen = false ))
578
578
})
@@ -583,6 +583,9 @@ export default {
583
583
},
584
584
585
585
methods: {
586
+ getTextareaRef () {
587
+ return this .$refs .roomTextarea .$refs .roomTextarea
588
+ },
586
589
touchStart (touchEvent ) {
587
590
if (this .singleRoom ) return
588
591
@@ -672,7 +675,7 @@ export default {
672
675
this .scrollIcon = bottomScroll > 500 || this .scrollMessagesCount
673
676
},
674
677
updateFooterList (tagChar ) {
675
- if (! this .$refs . roomTextarea ) return
678
+ if (! this .getTextareaRef () ) return
676
679
677
680
if (
678
681
tagChar === ' @' &&
@@ -686,12 +689,12 @@ export default {
686
689
}
687
690
688
691
if (
689
- this .textareaCursorPosition === this .$refs . roomTextarea .selectionStart
692
+ this .textareaCursorPosition === this .getTextareaRef () .selectionStart
690
693
) {
691
694
return
692
695
}
693
696
694
- this .textareaCursorPosition = this .$refs . roomTextarea .selectionStart
697
+ this .textareaCursorPosition = this .getTextareaRef () .selectionStart
695
698
696
699
let position = this .textareaCursorPosition
697
700
@@ -726,7 +729,7 @@ export default {
726
729
}
727
730
},
728
731
getCharPosition (tagChar ) {
729
- const cursorPosition = this .$refs . roomTextarea .selectionStart
732
+ const cursorPosition = this .getTextareaRef () .selectionStart
730
733
731
734
let position = cursorPosition
732
735
while (position > 0 && this .message .charAt (position - 1 ) !== tagChar) {
@@ -885,17 +888,18 @@ export default {
885
888
setTimeout (() => this .focusTextarea (disableMobileFocus))
886
889
},
887
890
resetTextareaSize () {
888
- if (! this .$refs .roomTextarea ) return
889
- this .$refs .roomTextarea .style .height = ' 20px'
891
+ if (this .getTextareaRef ()) {
892
+ this .getTextareaRef ().style .height = ' 20px'
893
+ }
890
894
},
891
895
focusTextarea (disableMobileFocus ) {
892
896
if (detectMobile () && disableMobileFocus) return
893
- if (! this .$refs . roomTextarea ) return
894
- this .$refs . roomTextarea .focus ()
897
+ if (! this .getTextareaRef () ) return
898
+ this .getTextareaRef () .focus ()
895
899
896
900
if (this .cursorRangePosition ) {
897
901
setTimeout (() => {
898
- this .$refs . roomTextarea .setSelectionRange (
902
+ this .getTextareaRef () .setSelectionRange (
899
903
this .cursorRangePosition ,
900
904
this .cursorRangePosition
901
905
)
@@ -904,7 +908,7 @@ export default {
904
908
}
905
909
},
906
910
preventKeyboardFromClosing () {
907
- if (this .keepKeyboardOpen ) this .$refs . roomTextarea .focus ()
911
+ if (this .keepKeyboardOpen ) this .getTextareaRef () .focus ()
908
912
},
909
913
sendMessage () {
910
914
let message = this .message .trim ()
@@ -1045,7 +1049,7 @@ export default {
1045
1049
this.$emit('typing-message', this.message)
1046
1050
}, 100),
1047
1051
resizeTextarea() {
1048
- const el = this.$refs.roomTextarea
1052
+ const el = this.getTextareaRef()
1049
1053
1050
1054
if (!el) return
1051
1055
0 commit comments