11// Copyright (c) Files Community
22// Licensed under the MIT License.
33
4+ using Windows . System ;
5+
46namespace Files . App . Controls
57{
68 public partial class Omnibar
79 {
810 private void Omnibar_SizeChanged ( object sender , SizeChangedEventArgs e )
911 {
12+ // Popup width has to be set manually because it doesn't stretch with the parent
1013 _textBoxSuggestionsContainerBorder . Width = ActualWidth ;
1114 }
1215
@@ -22,6 +25,10 @@ private void AutoSuggestBox_GotFocus(object sender, RoutedEventArgs e)
2225
2326 private void AutoSuggestBox_LostFocus ( object sender , RoutedEventArgs e )
2427 {
28+ // TextBox still has focus if the context menu for selected text is open
29+ if ( _textBox . ContextFlyout . IsOpen )
30+ return ;
31+
2532 _isFocused = false ;
2633
2734 if ( CurrentSelectedMode ? . ContentOnInactive is not null )
@@ -33,11 +40,38 @@ private void AutoSuggestBox_LostFocus(object sender, RoutedEventArgs e)
3340 TryToggleIsSuggestionsPopupOpen ( false ) ;
3441 }
3542
43+ private void AutoSuggestBox_KeyDown ( object sender , Microsoft . UI . Xaml . Input . KeyRoutedEventArgs e )
44+ {
45+ if ( e . Key is VirtualKey . Enter )
46+ {
47+ e . Handled = true ;
48+
49+ // TODO
50+ }
51+ else if ( ( e . Key == VirtualKey . Up || e . Key == VirtualKey . Down ) && _textBoxSuggestionsPopup . IsOpen )
52+ {
53+ e . Handled = true ;
54+
55+ // TODO
56+ }
57+ else if ( e . Key == VirtualKey . Escape && _textBoxSuggestionsPopup . IsOpen )
58+ {
59+ e . Handled = true ;
60+
61+ // TODO
62+ }
63+ else
64+ {
65+ // TODO
66+ }
67+ }
68+
3669 private void AutoSuggestBox_TextChanged ( object sender , TextChangedEventArgs e )
3770 {
38- if ( _shouldPopupOpen )
71+ // After a suggestion item was chosen, text will be changed but we don't want to show suggestions again
72+ if ( _suggestionWasClicked )
3973 {
40- _shouldPopupOpen = false ;
74+ _suggestionWasClicked = false ;
4175 return ;
4276 }
4377
@@ -68,7 +102,7 @@ private void AutoSuggestBoxSuggestionsListView_ItemClick(object sender, ItemClic
68102
69103 TryToggleIsSuggestionsPopupOpen ( false ) ;
70104
71- _shouldPopupOpen = true ;
105+ _suggestionWasClicked = true ;
72106 }
73107 }
74108}
0 commit comments