Skip to content

Temporary fix for issue #2.#14

Merged
lin-ycv merged 1 commit into
lin-ycv:IME-fix-0.1.0from
sht2017:tempfix
May 8, 2025
Merged

Temporary fix for issue #2.#14
lin-ycv merged 1 commit into
lin-ycv:IME-fix-0.1.0from
sht2017:tempfix

Conversation

@sht2017
Copy link
Copy Markdown
Contributor

@sht2017 sht2017 commented May 8, 2025

public abstract class DynamicListPage : ListPage, IDynamicListPage, IListPage, IPage, ICommand, INotifyPropChanged, INotifyItemsChanged
{
    public override string SearchText
    {
        get
        {
            return base.SearchText;
        }
        set
        {
            string searchText = base.SearchText;
            base.SearchText = value;
            UpdateSearchText(searchText, value);
        }
    }

    public abstract void UpdateSearchText(string oldSearch, string newSearch);
}

Bug from upstream:

As noted in issue #38829, PageViewModel.FetchProperty unconditionally raises PropertyChanged(SearchText) before the model’s SearchText is actually updated, so DynamicListPage’s default setter ends up reassigning the bound TextBox.Text prematurely—and WinUI always moves the caret to the end whenever you set Text in code .

Temporary Fix

By fully overriding SearchText and never calling base.SearchText = value, I completely bypass that race-y PropertyChanged + binding reassignment. Instead, I keep the query in our own private field and call UpdateSearchText(old, new) directly. this preserves real-time list updates while leaving the TextBox’s caret exactly where the user left it
GitHub.

Also, since it's a temp fix, I wish it could be merged to a new branch.

@sht2017
Copy link
Copy Markdown
Contributor Author

sht2017 commented May 8, 2025

Btw, I think there is no problem merging into the main branch - if you want to undo this temp fix, just delete the corresponding line. The original method upstream seems unlikely to be changed in the short term, so I think this should not cause problems.

@lin-ycv lin-ycv changed the base branch from main to IME-fix-0.1.0 May 8, 2025 14:39
@lin-ycv
Copy link
Copy Markdown
Owner

lin-ycv commented May 8, 2025

merging this into a new branch, since it's specific to 0.1.0
in 0.2.0 the fix is already implemented in cmdpal.

@lin-ycv lin-ycv merged commit 4384dae into lin-ycv:IME-fix-0.1.0 May 8, 2025
@sht2017 sht2017 deleted the tempfix branch May 16, 2025 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants