Browse Source

Fixed ComboBox.
All unit tests pass.

Tig 10 months ago
parent
commit
ee49337033

+ 1 - 5
Terminal.Gui/Views/ComboBox.cs

@@ -35,7 +35,6 @@ public class ComboBox : View, IDesignable
         _listview = new ComboListView (this, HideDropdownListOnClick) { CanFocus = true, TabStop = TabBehavior.NoStop };
 
         _search.TextChanged += Search_Changed;
-        _search.Accept += Search_Accept;
 
         _listview.Y = Pos.Bottom (_search);
         _listview.OpenSelectedItem += (sender, a) => Selected ();
@@ -315,7 +314,7 @@ public class ComboBox : View, IDesignable
             _search.CursorPosition = _search.Text.GetRuneCount ();
         }
         else
-        { 
+        {
             if (_source?.Count > 0
               && _selectedItem > -1
               && _selectedItem < _source.Count - 1
@@ -657,9 +656,6 @@ public class ComboBox : View, IDesignable
         SetSearchSet ();
     }
 
-    // Tell TextField to handle Accept Command (Enter)
-    void Search_Accept (object sender, HandledEventArgs e) { e.Handled = true; }
-
     private void Search_Changed (object sender, EventArgs e)
     {
         if (_source is null)

+ 3 - 4
Terminal.Gui/Views/RadioGroup.cs

@@ -130,10 +130,9 @@ public class RadioGroup : View, IDesignable, IOrientation
                         return true;
                     });
 
-        _orientationHelper = new (this)
-        {
-            Orientation = Orientation.Vertical
-        };
+        // ReSharper disable once UseObjectOrCollectionInitializer
+        _orientationHelper = new (this);
+        _orientationHelper.Orientation = Orientation.Vertical;
         _orientationHelper.OrientationChanging += (sender, e) => OrientationChanging?.Invoke (this, e);
         _orientationHelper.OrientationChanged += (sender, e) => OrientationChanged?.Invoke (this, e);
 

+ 4 - 0
UnitTests/Views/ComboBoxTests.cs

@@ -830,14 +830,18 @@ Three ",
         Assert.Equal (-1, cb.SelectedItem);
         Assert.Equal (string.Empty, cb.Text);
         var opened = false;
+
         cb.OpenSelectedItem += (s, _) => opened = true;
+
         Assert.True (Application.OnKeyDown (Key.Enter));
         Assert.False (opened);
+
         cb.Text = "Tw";
         Assert.True (Application.OnKeyDown (Key.Enter));
         Assert.True (opened);
         Assert.Equal ("Tw", cb.Text);
         Assert.False (cb.IsShow);
+
         cb.SetSource<string> (null);
         Assert.False (cb.IsShow);
         Assert.False (Application.OnKeyDown (Key.Enter));