Browse Source

Fix TextBox sync issues (#14960)

* Sync change text and changed caret index with the TextPresenter when text input is handled

* Do not add length again
release/11.1.0-beta2
Benedikt Stebner 2 years ago
committed by Max Katz
parent
commit
bacb59bc00
  1. 10
      src/Avalonia.Controls/TextBox.cs

10
src/Avalonia.Controls/TextBox.cs

@ -1063,7 +1063,15 @@ namespace Avalonia.Controls
_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);
}
}

Loading…
Cancel
Save