Skip to content

Commit

Permalink
Fix TextBox sync issues (AvaloniaUI#14960)
Browse files Browse the repository at this point in the history
* Sync change text and changed caret index with the TextPresenter when text input is handled

* Do not add length again
  • Loading branch information
Gillibald authored Mar 15, 2024
1 parent 6eb9d7a commit 1249a5f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Avalonia.Controls/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,15 @@ private void HandleTextInput(string? input)
_undoRedoHelper.DiscardRedo();
}

SetCurrentValue(CaretIndexProperty, caretIndex + input.Length);
//Make sure updated text is in sync
_presenter?.SetCurrentValue(TextPresenter.TextProperty, text);

caretIndex += input.Length;

//Make sure caret is in sync
_presenter?.MoveCaretToTextPosition(caretIndex);

SetCurrentValue(CaretIndexProperty, caretIndex);
}
}

Expand Down

0 comments on commit 1249a5f

Please sign in to comment.