Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/CommunityToolkit.Maui/Behaviors/MaskedBehavior.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,10 @@ static async void OnUnmaskedCharacterPropertyChanged(BindableObject bindable, ob

Task OnTextPropertyChanged(CancellationToken token)
{
#if ANDROID
// Android does not play well when we update the Text inside the TextChanged event. Therefore if we dispatch
// the mechanism of updating the Text property it solves the issue of the caret position being updated incorrectly.
Application.Current?.Dispatcher.Dispatch(async () => await ApplyMask(View?.Text, token));
return Task.CompletedTask;
#else
return ApplyMask(View?.Text, token);
#endif
// Android does not play well when we update the Text inside the TextChanged event.
// Therefore if we dispatch the mechanism of updating the Text property it solves the issue of the caret position being updated incorrectly.
// https://github.com/CommunityToolkit/Maui/issues/460
return View?.Dispatcher.DispatchAsync(() => ApplyMask(View?.Text, token)) ?? Task.CompletedTask;
}

void SetMaskPositions(in string? mask)
Expand Down