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 messes up with text composing in Trix. You may end
up with misspelled words when typing in the suggested term. For example:

Type: "kno".
iOS suggests "know".
Type: "w"
The final word is "knww".

The problem is the system that handles compositionend events, which relies on deleting the composed text.
When that only has one character, we default to performing a regular delete operation. 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 wrongly deleting legit content when discarding the suggestion.

This solution relaxes the condition to rely on the range when there is a length of one when the editor
is in composing mode.
  • Loading branch information
jorgemanrubia committed Jun 26, 2024
1 parent 0c79bcb commit c349489
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/trix/controllers/level_2_input_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ 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) {
return this.withTargetDOMRange(domRange, perform)
} else {
Expand Down

0 comments on commit c349489

Please sign in to comment.