Improve AutoCompleteBox focus behavior for 11.3.x (#761)

* feat: improve AutoCompleteBox focus behavior for 11.3.x

* fix: open dropdown on tab navigation regardless of navigation method

* feat: update per copilot comment.

* feat: add a flag to control focus.

* fix: fix naming.
This commit is contained in:
Dong Bin
2025-09-10 21:30:56 +08:00
committed by GitHub
parent 7e35b880bb
commit e163d671ab
2 changed files with 71 additions and 5 deletions

View File

@@ -14,11 +14,18 @@
Name="PART_TextBox"
MinHeight="{TemplateBinding MinHeight}"
VerticalAlignment="Stretch"
iri:ClassHelper.ClassSource="{TemplateBinding}"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
InnerLeftContent="{TemplateBinding InnerLeftContent}"
InnerRightContent="{TemplateBinding InnerRightContent}"
Watermark="{TemplateBinding Watermark}" />
<Button
Name="PART_ClearButton"
HorizontalAlignment="Right"
Margin="{DynamicResource TextBoxContentPadding}"
Command="{Binding $parent[u:AutoCompleteBox].Clear}"
Content="{DynamicResource IconButtonClearData}"
IsVisible="False"
Theme="{StaticResource InnerIconButton}" />
<Popup
Name="PART_Popup"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
@@ -45,5 +52,13 @@
</Panel>
</ControlTemplate>
</Setter>
<Style Selector="^.clearButton, ^.ClearButton">
<Style Selector="^:focus-within:not(:empty) /template/ Button#PART_ClearButton">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="^:pointerover:not(:empty) /template/ Button#PART_ClearButton">
<Setter Property="IsVisible" Value="True" />
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>