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

AutoCompleteBox does not have a clear event for when the user is "done" #17667

Open
svbnet opened this issue Dec 2, 2024 · 2 comments
Open

Comments

@svbnet
Copy link

svbnet commented Dec 2, 2024

Is your feature request related to a problem? Please describe.

The AutoCompleteBox control is useful for forms, where the user may need to select a specific item from a list of many items, but is not very suitable for cases like text searching. Ideally it would act like:

  1. User enters a search term and presses enter, parent receives it (e.g. through an event) and does something like load a results page
  2. User enters a search term and keys down to a suggestion, parent receives it and loads a different page
  3. User enters a search term and clicks a suggestion, above happens

Currently,

  1. Can't happen as in the OnKeyDown event handler the enter key is handled, so the only workaround is to subclass the control or add an event handler to SelectionAdapter.Commit
  2. Can't happen because the enter key is handled
  3. Can't happen because the selected item can also change if the user keys up or down on the suggestions

The alternative is to add an event handler to SelectionAdapter.Commit, which is triggered on all of the above conditions. However, I'm not a fan of this exactly since there is the potential for SelectionAdapter to change without notification to the parent. Additionally it's only initially set when TemplatedApplied is triggered.

Describe the solution you'd like

I have a commit which leverages the private OnAdapterSelectionComplete method to raise a new event, Submitted: svbnet@8940078

This accomplishes it in what I think is a more elegant way. I am not set on the name, if you have any ways to improve this then I would like to hear them.

Describe alternatives you've considered

As above, the only alternatives I have found involve adding an event handler to SelectionAdapter.Commit.

Additional context

Let me know if I'm headed down a completely wrong path here, I am raising this though as I've gotten quite far with AutoCompleteBox except for the actual interaction part.

@timunie
Copy link
Contributor

timunie commented Dec 2, 2024

  1. You can tunnel the event
  2. I bind to Text and start searching after a delay of 500 ms. So search auto updates but not as frequently as a typical user types

@svbnet
Copy link
Author

svbnet commented Dec 2, 2024

For #2 that isn't a feasible option as displaying search results is very expensive (multiple web requests and image fetches)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants