From ea1c2a34e23286649567220e6a5cc256073766de Mon Sep 17 00:00:00 2001 From: kuaifan Date: Fri, 9 Jun 2023 13:58:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20safari=20=E6=B6=88=E6=81=AF=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E7=84=A6=E7=82=B9=E6=BA=A2=E5=87=BA=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/manage/components/ChatInput/index.vue | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue index 4aefb09f3..74305fada 100755 --- a/resources/assets/js/pages/manage/components/ChatInput/index.vue +++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue @@ -276,6 +276,8 @@ export default { pasteClean: true, isSpecVersion: this.checkIOSVersion(), + + timer: null, }; }, mounted() { @@ -710,14 +712,13 @@ export default { // Mark model as touched if editor lost focus this.quill.on('selection-change', range => { - if (!range) { + if (!range && document.activeElement) { // 修复光标会超出的问题 - if (this.quill.hasFocus()) { - this.quill.setSelection(0) - return - } - if (document.activeElement && document.activeElement.className === 'ql-clipboard') { - this.quill.setSelection(this.quill.getLength()) + if (['ql-editor', 'ql-clipboard'].includes(document.activeElement.className)) { + this.timer && clearTimeout(this.timer) + this.timer = setTimeout(_ => { + this.quill.setSelection(document.activeElement.className === 'ql-editor' ? 0 : this.quill.getLength()) + }, 100) return } }