Skip to content

Commit

Permalink
Fixes #1227
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Feb 6, 2025
1 parent eb9a3c0 commit da6bfc0
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Fluent.Ribbon/Controls/DropDownButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -578,20 +578,14 @@ 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;

if (timespan <= 0)
// Ugly workaround, but use a timer to allow routed event to continue
Task.Factory.StartNew(async () =>
{
this.IsDropDownOpen = false;
}
else
{
// Ugly workaround, but use a timer to allow routed event to continue
Task.Factory.StartNew(async () =>
{
await Task.Delay(timespan);
// 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));

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

Expand Down

1 comment on commit da6bfc0

@TAlecksen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this. Based on your edits, I'm not sure it will fix the issue since I can also set the timespan to 20 and it still does not work. Ideally, I would like to leave it set to the default 100 ms time but the delay is enough to where the menu stays open in front of a control that I need to show quickly. Do you know of any other workarounds that might allow quicker closing of the menu?

Please sign in to comment.