Skip to content

Commit

Permalink
Fixes #1227
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Feb 9, 2025
1 parent b1abcb7 commit 771f618
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Fluent.Ribbon/Controls/DropDownButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ public bool ClosePopupOnMouseDown
/// <summary>
/// Gets or sets the delay in milliseconds to close the popup on mouse down.
/// </summary>
/// <remarks>
/// The minimum used delay is 100 ms, no matter which value is set.
/// </remarks>
public int ClosePopupOnMouseDownDelay
{
get => (int)this.GetValue(ClosePopupOnMouseDownDelayProperty);
Expand Down Expand Up @@ -578,11 +581,11 @@ private void OnDropDownPopupMouseDown(object sender, RoutedEventArgs e)
// Note: get outside thread to prevent exceptions (it's a dependency property after all)
var timespan = this.ClosePopupOnMouseDownDelay;

// Ugly workaround, but use a timer to allow routed event to continue
// Ugly workaround, but use a task to allow routed event to continue
Task.Factory.StartNew(async () =>
{
// We need at least 1 ms of delay. Otherwise there is no way for the routed event to continue
await Task.Delay(Math.Max(1, timespan));
// We need at least 100 ms of delay. Otherwise there is no way for the routed event to continue...
await Task.Delay(Math.Max(100, timespan));

this.RunInDispatcherAsync(() => this.IsDropDownOpen = false);
});
Expand Down

0 comments on commit 771f618

Please sign in to comment.