fix: 修复移动端焦点抖动的问题

This commit is contained in:
kuaifan 2025-04-08 08:49:30 +08:00
parent 397421010e
commit 6f7edd0b40

View File

@ -988,7 +988,7 @@ export default {
// Mark model as touched if editor lost focus // Mark model as touched if editor lost focus
this.quill.on('selection-change', range => { this.quill.on('selection-change', range => {
if (!inputLoadIsLast(this._uid)) { if (!this.inputActivated()) {
return; return;
} }
if (range) { if (range) {
@ -1247,6 +1247,10 @@ export default {
}, 100) }, 100)
}, },
inputActivated() {
return !this.fullInput && inputLoadIsLast(this._uid)
},
getEditor() { getEditor() {
return this.fullInput ? this.fullQuill : this.quill return this.fullInput ? this.fullQuill : this.quill
}, },
@ -1294,6 +1298,7 @@ export default {
onClickEditor() { onClickEditor() {
this.clearSearchKey() this.clearSearchKey()
this.updateEmojiQuick(this.value) this.updateEmojiQuick(this.value)
inputLoadAdd(this._uid)
}, },
clearSearchKey() { clearSearchKey() {
@ -1731,7 +1736,15 @@ export default {
} }
}, this.options)) }, this.options))
this.fullQuill.on('selection-change', range => { this.fullQuill.on('selection-change', range => {
this.fullSelection = range || {index: 0, length: 0}; if (range) {
this.fullSelection = range
} else if (this.fullSelection && document.activeElement && /(ql-editor|ql-clipboard)/.test(document.activeElement.className)) {
// iOS
this.selectTimer && clearTimeout(this.selectTimer)
this.selectTimer = setTimeout(_ => {
this.fullQuill.setSelection(this.fullSelection.index, this.fullSelection.length)
}, 100)
}
}) })
this.fullQuill.on('text-change', _ => { this.fullQuill.on('text-change', _ => {
this.fullSelection = this.fullQuill.getSelection() this.fullSelection = this.fullQuill.getSelection()
@ -1900,7 +1913,7 @@ export default {
if (!this.quill) { if (!this.quill) {
return; return;
} }
if (!inputLoadIsLast(this._uid)) { if (!this.inputActivated()) {
return; return;
} }
const {index} = this.quill.getSelection(true); const {index} = this.quill.getSelection(true);