Skip to content

feat(AutoSuggestBox): add ShowSuggestionsOnFocus property#4077

Draft
corvinsz wants to merge 6 commits into
MaterialDesignInXAML:masterfrom
corvinsz:feat/AutoSuggestBox-ShowOnSuggestionsOnFocus
Draft

feat(AutoSuggestBox): add ShowSuggestionsOnFocus property#4077
corvinsz wants to merge 6 commits into
MaterialDesignInXAML:masterfrom
corvinsz:feat/AutoSuggestBox-ShowOnSuggestionsOnFocus

Conversation

@corvinsz

@corvinsz corvinsz commented Jul 4, 2026

Copy link
Copy Markdown
Member

Initially I just wanted to add a search dialog (blatantly stolen from mudblazor). While doing so, I noticed a few things with the AutoSuggestBox.

Demo app changes

Added a shortcut Ctrl+K to open a dialog so users can search and jump to pages using hotkeys.

MD2 app MD3 app
image image

AutoSuggestBox changes

  1. added a new DP ShowSuggestionsOnFocus
  2. override OnGotFocus method to open the suggestion listbox when ShowSuggestionsOnFocus="True"
  3. Removed the e.Handled="true" in the OnPreviewKeyDown. With this in place, consumers can't have custom actions on the AutoSuggestBox on the call-site. For example handling the Esc key to close the search-dialog (like I have done it in the demo apps).
    For some reason I can't reproduce the bug that e.Handled="true" was supposed to fix.
  4. Some refactoring and performance improvement (GetItemCount())
  5. Added Placement="Bottom" and PlacementTarget="{Binding ElementName=OuterBorder}" to the PopupEx, because without it the popup wouldn't update it's position when moving the window:
image
  1. With StaysOpen="False" the list wasn't reliably opened, so I changed it to true (e.g. open search dialog -> move window -> focus the AutoSuggestBox again and see that the list wouldn't open again)
  2. Added tests to validate the new behavior

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.

1 participant