Skip to content

Commit

Permalink
Limit EditContext change-while-composition trick
Browse files Browse the repository at this point in the history
FIX: Work around an issue with Chrome's `EditContext` that shows up
when using autocompletion while composing with Samsung's virtual Android
keyboard.

Issue codemirror/dev#1504
  • Loading branch information
marijnh committed Jan 28, 2025
1 parent 4bdec39 commit ee2c8aa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/domobserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,11 @@ class EditContextManager {
}

update(update: ViewUpdate) {
let reverted = this.pendingContextChange
if (this.composing && (this.composing.drifted || update.transactions.some(
tr => !tr.isUserEvent("input.type") && tr.changes.touchesRange(this.from, this.to)))) {
let reverted = this.pendingContextChange, startSel = update.startState.selection.main
if (this.composing &&
(this.composing.drifted ||
(!update.changes.touchesRange(startSel.from, startSel.to) &&
update.transactions.some(tr => !tr.isUserEvent("input.type") && tr.changes.touchesRange(this.from, this.to))))) {
this.composing.drifted = true
this.composing.editorBase = update.changes.mapPos(this.composing.editorBase)
} else if (!this.applyEdits(update) || !this.rangeIsValid(update.state)) {
Expand Down

0 comments on commit ee2c8aa

Please sign in to comment.