@@ -22,8 +22,12 @@ namespace Files.App.Controls
2222 public partial class Omnibar : Control
2323 {
2424 private const string ModesHostGrid = "PART_ModesHostGrid" ;
25+ private const string AutoSuggestPopup = "PART_AutoSuggestPopup" ;
26+ private const string AutoSuggestBoxBorder = "PART_AutoSuggestBoxBorder" ;
2527
2628 private Grid ? _modesHostGrid ;
29+ private Popup ? _autoSuggestPopup ;
30+ private Border ? _autoSuggestBoxBorder ;
2731 private bool _wasAscendantFocused ;
2832 private bool _isFocused ;
2933
@@ -38,6 +42,10 @@ protected override void OnApplyTemplate()
3842 {
3943 _modesHostGrid = GetTemplateChild ( ModesHostGrid ) as Grid
4044 ?? throw new MissingFieldException ( $ "Could not find { ModesHostGrid } in the given { nameof ( Omnibar ) } 's style.") ;
45+ _autoSuggestPopup = GetTemplateChild ( AutoSuggestPopup ) as Popup
46+ ?? throw new MissingFieldException ( $ "Could not find { AutoSuggestPopup } in the given { nameof ( Omnibar ) } 's style.") ;
47+ _autoSuggestBoxBorder = GetTemplateChild ( AutoSuggestBoxBorder ) as Border
48+ ?? throw new MissingFieldException ( $ "Could not find { AutoSuggestBoxBorder } in the given { nameof ( Omnibar ) } 's style.") ;
4149
4250 if ( Modes is null )
4351 return ;
@@ -68,9 +76,10 @@ protected override void OnApplyTemplate()
6876 mode . Host = this ;
6977 }
7078
79+ _modesHostGrid . SizeChanged += _modesHostGrid_SizeChanged ;
80+
7181 var parentElement = this . FindAscendant < FrameworkElement > ( ) ! ;
7282 parentElement . PointerPressed += ParentElement_PointerPressed ;
73-
7483 GotFocus += Omnibar_GotFocus ;
7584 LostFocus += Omnibar_LostFocus ;
7685
@@ -113,6 +122,11 @@ private void UpdateVisualStates()
113122
114123 // Events
115124
125+ private void _modesHostGrid_SizeChanged ( object sender , SizeChangedEventArgs e )
126+ {
127+ _autoSuggestBoxBorder ! . Width = _modesHostGrid ! . ActualWidth ;
128+ }
129+
116130 private void ParentElement_PointerPressed ( object sender , PointerRoutedEventArgs e )
117131 {
118132 // Lost focus
@@ -137,12 +151,16 @@ private void Omnibar_GotFocus(object sender, RoutedEventArgs e)
137151
138152 _isFocused = true ;
139153 UpdateVisualStates ( ) ;
154+
155+ _autoSuggestPopup ! . IsOpen = true ;
140156 }
141157
142158 private void Omnibar_LostFocus ( object sender , RoutedEventArgs e )
143159 {
144160 _isFocused = _wasAscendantFocused = false ;
145161 UpdateVisualStates ( ) ;
162+
163+ _autoSuggestPopup ! . IsOpen = false ;
146164 }
147165 }
148166}
0 commit comments