Skip to content

Conversation

DanBiscotti
Copy link

@DanBiscotti DanBiscotti commented Apr 8, 2025

fixes #1546

  • I have read the Contribution Guidelines
  • I have commented on the issue above and discussed the intended changes
  • A maintainer has signed off on the changes and the issue was assigned to me
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors
  • The documentation was modified to reflect the changes OR no documentation changes are required.

Changes

I changed the code so that now when a user searches, the list is filtered down to only those items which match the search term

ListPromptState.cs

There are now 3 lists which hold the current state of the prompt:

  • Items This existed before and contains all the items
  • VisibleItems This list contains only items which match the search term, or any groups which contain a child which matches the search term
  • _selectableItems This list contains only the subset of VisibleItems which are selectable (ie. not a group if in leaf mode, following the same logic as before with _leafIndexes). it is a list of SelectableItem which contains the ListPromptItem and also the index of the item in VisibleItems.

VisibleItems and _selectableItems are updated every time the search term changes, when the user is navigates the list the only the index of the item in _selectableItems is updated (which is stored in _selectableIndex).

ListPrompt.cs

  • BuildRenderable now uses VisibleItems
  • added argument for filterOnSearch

SelectionPrompt.cs

  • added FilterOnSearch property
  • Removed the spacebar as a key which submits, to allow the search to contain spaces
  • Added null check for when state.Current == null. This happens when the VisibleItems is filtered to the point it contains no items
  • removed skipUnselectableItems argument as it wasn't being used

SelectionPromptExtensions.cs

  • Added optional bool to the EnableSearch method to set FilterOnSearch

MultiSelectionPrompt.cs

  • added argument for filterOnSearch
  • removed skipUnselectableItems argument as it wasn't being used

IListPromptStrategy

  • removed skipUnselectableItems argument as it wasn't being used

Please upvote 👍 this pull request if you are interested in it.

@DanBiscotti
Copy link
Author

I realize it's not perfect yet, but would be good to hear what you think of the idea, I haven't made a PR in the repo before so apologies if I've missed something!

@DanBiscotti
Copy link
Author

@microsoft-github-policy-service agree

@arfazca
Copy link

arfazca commented Apr 18, 2025

Just wondering if there's any update on this? I'm currently working on a project that requires search functionality with spaces, so it would be great to have this merged. @DanBiscotti Appreciate your time and efforts on the project!

missed return true statement
@github-actions github-actions bot added the ⭐ top pull request Top pull request. label Apr 19, 2025
@github-actions github-actions bot added ⭐ top pull request Top pull request. and removed ⭐ top pull request Top pull request. labels Aug 3, 2025
@github-actions github-actions bot removed the ⭐ top pull request Top pull request. label Aug 23, 2025
@github-actions github-actions bot added the ⭐ top pull request Top pull request. label Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⭐ top pull request Top pull request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for multiple matching search result items with the SelectionPrompt

2 participants