Skip to content

Commit

Permalink
Fixes #989 by closing popup of DropDownButton when it gets invisible
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Nov 26, 2021
1 parent faf5b6b commit b64e5eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- [#954](../../issues/954) - Adding an InputBinding for Alt+Up or Alt+Down results in extra character (thanks @dgosbell)
- [#961](../../issues/961) - Fluent.Button Header Binding not visible
- [#973](../../issues/973) - Wrong reference to ControlzEx
- [#989](../../issues/989) - QuickAccessToolbar - More Commands leaves open empty Popup when overflow gets empty

- ### Enhancements/Features
- [#924](../../issues/924) - Feature simplified ribbon (thanks @nishy2000)
Expand Down
7 changes: 7 additions & 0 deletions Fluent.Ribbon/Controls/DropDownButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,18 @@ public DropDownButton()

this.Loaded += this.OnLoaded;
this.Unloaded += this.OnUnloaded;
this.IsVisibleChanged += this.OnIsVisibleChanged;

this.AddHandler(System.Windows.Controls.MenuItem.SubmenuOpenedEvent, new RoutedEventHandler(this.OnSubmenuOpened));
this.AddHandler(System.Windows.Controls.MenuItem.SubmenuClosedEvent, new RoutedEventHandler(this.OnSubmenuClosed));
}

private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
// We should better use code similar to ComboBox.OnLostMouseCapture, but most of the methods called there are internal to WPF...
this.SetCurrentValue(IsDropDownOpenProperty, BooleanBoxes.FalseBox);
}

private void OnLoaded(object sender, RoutedEventArgs e)
{
this.SubscribeEvents();
Expand Down
2 changes: 1 addition & 1 deletion Fluent.Ribbon/Controls/QuickAccessToolBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private void OnItemsCollectionChanged(object? sender, NotifyCollectionChangedEve
// Raise items changed event
this.ItemsChanged?.Invoke(this, e);

if (this.Items.Count == 0
if ((this.Items.Count == 0 || this.cachedNonOverflowItemsCount == this.Items.Count)
&& this.toolBarDownButton is not null)
{
this.toolBarDownButton.IsDropDownOpen = false;
Expand Down

0 comments on commit b64e5eb

Please sign in to comment.