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

Wrap selection in the AutoSuggestBox #3817

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

Conversation

corvinsz
Copy link
Member

fixes #3815

As shown in the linked issue, currently users can null the SelectedItem of the internal ListBox using the up/down arrow keys.

@Keboo I also tried to add tests for this case, but I can't get it to work. It might be a me-problem, but I couldn't figure out how to access the ItemSource/Suggestions of the AutoSuggestBox. Instead of the actual suggestions, I got back a List of characters saying "(Collection)":
image

I need the ItemSource/Suggestions to assert that the "last" (Suggestions.Count - 1) item is selected. Could this be a bug with your XAML test library or am I simply using it wrong?

@Keboo
Copy link
Member

Keboo commented Mar 21, 2025

So what is happening is XAMLTest runs two processes, one for the test and one for the WPF App. For all of the dependency properties it generates extension methods for the getters and setters. However, for the values to flow back and forth from the WPF process to the test process they must be serialized. The fallback is to just .ToString() the value which is why you see that result.

There is an escape hatch option, which lets you declare a method in your test code, that will be executed from the WPF process. As long as you make its return type something that can be serialized, you can pass back whatever you want.

In the suggestion below I do this to get the count of the suggestions by directly acting on the AutoSuggestBox.

Hey @corvinsz, while reviewing your PR, I'd suggest the following code changes:

👉 Code Suggestion for #3817

#3817

You can also review and apply these suggestions locally on your machine.

Learn more about GitKraken Code Suggest

Code Suggest liberates your code reviews from GitHub's restrictive, comment-only feedback style. As simple as suggesting changes in a Google-doc, provide real code suggestions from where you code, e.g. your IDE, and on anything in your project — not just on the lines of code changed in the PR.

Join your team on GitKraken to speed up PR review.

@corvinsz
Copy link
Member Author

Ah I see.. I wasn't aware of that. Thanks for the explanation 😊
I applied your suggestions to this PR.

@corvinsz corvinsz marked this pull request as ready for review March 21, 2025 15:08
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.

AutoSuggestBox: Input Text Disappears After Deselecting Suggestion and Pressing TAB/ENTER
2 participants