Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/MaterialDesignThemes.Wpf/PopupBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)

private void ToggleButtonOnPreviewMouseLeftButtonUp(object? sender, MouseButtonEventArgs mouseButtonEventArgs)
{
if (PopupMode == PopupBoxPopupMode.Click || !IsPopupOpen) return;
if (!IsPopupOpen) return;

if (ToggleCheckedContent != null)
{
Expand Down
29 changes: 29 additions & 0 deletions tests/MaterialDesignThemes.UITests/WPF/PopupBoxes/PopupBoxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,33 @@ await Wait.For(async () =>
await Assert.That(await border.GetBackgroundColor()).IsEqualTo(Colors.Red);
});
}

[Test]
[Description("https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/2280")]
public async Task PopupBox_WhenInOpenedState_ClosesWhenClicked()
{
//Arrange
IVisualElement<PopupBox> popupBox = await LoadXaml<PopupBox>("""
<materialDesign:PopupBox Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}" IsPopupOpen="True">
<StackPanel>
<Button Content="1" />
<Button Content="2" />
<Button Content="3" />
</StackPanel>
</materialDesign:PopupBox>
""");
bool isOpen = await popupBox.GetIsPopupOpen();
await Assert.That(isOpen).IsTrue();

//Act
IVisualElement<ToggleButton> toggleButton = await popupBox.GetElement<ToggleButton>("/ToggleButton");
await toggleButton.LeftClick();

//Assert
await Wait.For(async () =>
{
isOpen = await popupBox.GetIsPopupOpen();
await Assert.That(isOpen).IsFalse();
});
}
}
Loading