Don't move the caret to the end of the input if nothing changed (#374)

Title.

I just noticed that if you move the caret earlier in the input, then type, we'll toss the caret to the end of the input. Ew. Don't do that.

We should only move the caret if the text actually changed from what we already had.
This commit is contained in:
Mike Griese
2025-01-27 14:06:09 -06:00
committed by GitHub
parent a89375df1e
commit 899c233329

View File

@@ -240,10 +240,16 @@ public sealed partial class SearchBar : UserControl,
if (CurrentPageViewModel is ListViewModel list &&
property == nameof(ListViewModel.SearchText))
{
FilterBox.Text = list.SearchText;
// Only if the text actually changed...
// (sometimes this triggers on a round-trip of the SearchText)
if (FilterBox.Text != list.SearchText)
{
// ... Update our displayed text, and...
FilterBox.Text = list.SearchText;
// Move the cursor to the end of the input
FilterBox.Select(FilterBox.Text.Length, 0);
// ... Move the cursor to the end of the input
FilterBox.Select(FilterBox.Text.Length, 0);
}
}
}