Skip to content

Commit

Permalink
fix: Fix selector item incorrectly going to Normal visual state
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Mar 27, 2024
1 parent ea9a374 commit a20bd17
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ public void Init()
const int BorderThicknessAdjustment = 2; // Deduct BorderThickness on PopupBorder

#if HAS_UNO
[TestMethod]
[DataRow(0)]
[DataRow(1)]
[DataRow(2)]
public async Task When_ReOpened_Remains_Selected_VisualState(int selectedIndex)
{
var SUT = new ComboBox();
var items = new[] { "First", "Second", "Third" };
SUT.ItemsSource = items;
await UITestHelper.Load(SUT);

SUT.IsDropDownOpen = true;
await TestServices.WindowHelper.WaitForIdle();
SUT.SelectedIndex = selectedIndex;
await TestServices.WindowHelper.WaitForIdle();
SUT.IsDropDownOpen = false;
await TestServices.WindowHelper.WaitForIdle();
SUT.IsDropDownOpen = true;
await TestServices.WindowHelper.WaitForIdle();
var container = (ComboBoxItem)SUT.ContainerFromItem(items[selectedIndex]);
Assert.AreEqual("Selected", VisualStateManager.GetCurrentState(container, "CommonStates").Name);
}

[TestMethod]
public async Task When_IsEditable_False()
{
Expand Down
3 changes: 0 additions & 3 deletions src/Uno.UI/UI/Xaml/Controls/Primitives/SelectorItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@ internal override void PrepareForRecycle()
// ListView to get a clicked container.
ClearValue(ItemsControl.IndexForItemContainerProperty);

// Reset visual state so that the container doesn't come back looking like it's hovered or clicked.
VisualStateManager.GoToState(this, "Normal", false);

base.PrepareForRecycle();
}

Expand Down

0 comments on commit a20bd17

Please sign in to comment.