-
Notifications
You must be signed in to change notification settings - Fork 70
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
[Feature] Ability for TokenizingTextBox to keep the typed text after submitting or selecting #168
[Feature] Ability for TokenizingTextBox to keep the typed text after submitting or selecting #168
Comments
Hello, 'smumovic! Thanks for submitting a new feature request. I've automatically added a vote 👍 reaction to help get things started. Other community members can vote to help us prioritize this feature in the future! |
@niels9001 thoughts on the property name? Maybe We could theoretically add this to the Windows/components/TokenizingTextBox/src/TokenizingTextBox.cs Lines 494 to 516 in acb5a1f
Main difficulty there is passing back the result of that to the call from Windows/components/TokenizingTextBox/src/TokenizingTextBoxItem.AutoSuggestBox.cs Lines 154 to 156 in acb5a1f
|
Sounds good to me 👍! |
Describe the problem
I'm using the TokenizingTextBox to implement an advanced quick search in my application. When a user starts typing, they first get a list of fields they can search through, and when selecting one the selected field appears as a token in the search box letting the user know they are searching only for that field. They can select several fields to search through all the selected ones.
The trouble is that every time the TTB is submitted (by pressing enter or by selecting an item from the suggestions) the Text property is emptied. I have to resort to cheating it via "TokenItemAdding" and "GotFocus" events (to store the text in a temp string, and restore it after the "QuerySubmitted" event has executed, as I noticed in the source code for the TTB that the QuerySubmitted event actually empties the Text property.
Describe the solution
I found the exact place the TTB empties the Text field (lines 156 and 157 of the TokenizingTextBoxItem.cs):
My proposal is to surround the two lines that empty the text with a conditional statement dependent on a top-level property that can be set in XAML, something like KeepTextInputAfterQuerySubmit defaulted to false to keep it backward compatible.
I tested it in a branch ad it behaves exactly like I need it to behave (I commented out the two lines to get a quick feel).
I can put in the work to properly introduce the property in the XAML and all the in-between code in order to make it proper and submit a PR. I just need acceptance by the community to get the PR approved.
Alternatives
One alternative is to introduce a PostQuerySubmitted event that i can use to restor the text box content. But this is less elegant and there will be a slight delay when the filed will be empty.
Yet another alternative is to enable the component to be extended and the original QuerySubmitted method overridden, but this is much more trouble than its worth IMHO.
Additional info
This is an example from my modified component that keeps the text:
I achieved this by commenting out the two lines and testing it in the Sample App. The text is kept in the text box after typing and selecting one of the offered options. It creates the token, but the text can be used to refine the search after the results have been loaded (in my use case).
Help us help you
Yes, I'd like to be assigned to work on this item.
The text was updated successfully, but these errors were encountered: