Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search all SelectingItemsControl items with TextSearch on key input, not just realized ones #17506

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

jonko0493
Copy link

@jonko0493 jonko0493 commented Nov 14, 2024

What does the pull request do?

This PR brings the behavior of SelectingItemControls with VirtualizingPanel presenters into parity with those controls without virtualizing presenters.

What is the current behavior?

Currently, SelectingItemsControls with VirtualizingPanel item presenters (such as ComboBox) do not search the full contents of their boxes with text search, only the currently realized controls. This means that if a ComboBox is closed, typing does nothing, and even when opened, (this was slightly wrong!) it will only jump to items immediately in the popup.

What is the updated/expected behavior with this PR?

Now, ComboBoxes and other SelectingItemsControls with virtualizing presenters will have proper TextSearch for their entire item sets.

How was the solution implemented (if it's not obvious)?

The anonymous method that existed in the SelectingItemsControl class previously has been moved into a static method in ItemsPresenter. It's now used there and in VirtualizingPanel to check search their items/children for text search. (Note: I don't know if there is a preferred place for a static method like this; happy to move as appropriate.)

Unit test case was added to an existing test and the test was adapted so that ComboBoxes in tests will use a VirtualizingStackPanel like the real controls do to ensure the tests fail without this change.

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

Fixes #12490.

@jonko0493 jonko0493 changed the title [SelectingItemsControl] Search all items with TextSearch on key input, not just realized ones Search all SelectingItemsControl items with TextSearch on key input, not just realized ones Nov 14, 2024
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0053300-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@cla-avalonia
Copy link
Collaborator

cla-avalonia commented Nov 14, 2024

  • All contributors have signed the CLA.

@jonko0493
Copy link
Author

@cla-avalonia agree

@jonko0493
Copy link
Author

Everything was passing prior to me merging master... not sure what changed, could be transient failures?

@timunie
Copy link
Contributor

timunie commented Nov 17, 2024

@jonko0493 don't worry tests are a bit flaky atm

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0053407-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0053771-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0053885-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0053987-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@jonko0493
Copy link
Author

Hi folks! Is there something more I need to do to get this reviewed? It is needed for the application I'm developing and it's been a month since it was opened. Thanks!

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0054097-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@jonko0493
Copy link
Author

@timunie I'm very sorry to ping you, but I'm wondering if there's anything else I need to do to get this reviewed. It's needed to make my project usable and I'd prefer not to take a dependency on the PR package. Please let me know if there's anything I can do!

@timunie
Copy link
Contributor

timunie commented Jan 12, 2025

If you have paid support please ask for priority

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0054235-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@jonko0493
Copy link
Author

@timunie I don't have paid support as we're a tiny open source project, so fair enough, I'll wait my turn. This PR has been open three months -- how long should I expect to wait before getting a review without paid support?

@MikeCodesDotNET
Copy link
Member

Thanks for bearing with us. To clarify, this PR was submitted on 14th November, so it’s been open for less than two months, not three.

As an open-source project, we greatly value community contributions, but our priority is supporting paying customers. While we can’t guarantee review times for community PRs, we aim to review them as quickly as possible.

We’re planning to allocate time this week to address outstanding contributions, though I can’t promise which specific PRs will be reviewed.

Copy link
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.

While the implementation has its merits, we now have different behaviors for standard panels and for VirtualizingPanel.
The non-virtualized implementation searches inside item containers (controls) directly. The new implementation for VirtualizingPanel searches only inside Items.

We should have the same implementation for both panels here, for consistency.
Looking at WPF, it always searches in Items, so I propose that we do the same, whatever the panel.

The search should look for:

  • TextSearch.Text (current)
  • IContentControl.Content.ToString() (current)
  • item.ToString()

(Ideally we'd also consider DisplayMemberBinding, like WPF does, but this is out of scope of this PR and can be added later).

/// </summary>
/// <param name="textSearchTerm">The beginning of a string (case-insensitive) to search for in the panel</param>
/// <returns>The index of the first IContentControl item contained in the panel</returns>
protected internal int GetIndexFromTextSearch(string textSearchTerm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the protected modifier, this method shouldn't be exposed as public API.

/// <returns>The index of the first IContentControl item contained in the panel</returns>
protected internal int GetIndexFromTextSearch(string textSearchTerm)
{
var matchingControl = Items.FirstOrDefault(i => i is Control c && ItemsPresenter.ControlMatchesTextSearch(c, textSearchTerm));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a single loop, and check each item for ControlMatchesText then ToString(), keeping the old behavior.

@jonko0493
Copy link
Author

@MikeCodesDotNET Thanks so much for letting me know and I'm sorry for misrepresenting how long the PR had been open -- that was truly a mistake on my part (I can't do date math well in my head, apparently lol).

@MrJul Thank you for the review! The changes you've suggested make good sense. I'll make them in the next few days.

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.

[SelectingItemsControl] TextSearch in all items, not only realized items
6 participants