Skip to content

Commit

Permalink
Fix problem with iOS beta 8 suggestions
Browse files Browse the repository at this point in the history
iOS beta 8 renders a preview of the suggestion that was messing up with text composing in Trix.

The problem is that the system to handle "compositionend" events, which relies on deleting
the composed text. When that only has one character we default to perform a regular delete. The problem
with the new iOS dimmed suggestions is that this matches the interaction of typing in the last character
 in a suggestion, and it results in Trix wrong deleting legit content when discarding the suggestion.

This solution relaxes the condition to rely on the range when there is has a length of 1 when the editor is in
composing mode.
  • Loading branch information
jorgemanrubia committed Jun 26, 2024
1 parent 0c79bcb commit 91aa8a5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/trix/controllers/level_2_input_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,9 @@ export default class Level2InputController extends InputController {
this.delegate?.inputControllerWillPerformTyping()
}
const perform = () => this.responder?.deleteInDirection(direction)
const domRange = this.getTargetDOMRange({ minLength: 2 })
const domRange = this.getTargetDOMRange({ minLength: this.composing ? 1 : 2 })
if (domRange) {
const domRange = this.getTargetDOMRange({ minLength: this.composing ? 1 : 2 })
return this.withTargetDOMRange(domRange, perform)
} else {
return perform()
Expand Down

0 comments on commit 91aa8a5

Please sign in to comment.