ControlCatalog: Side-menu toggling breaks after a page is opened
See original GitHub issueDescribe the bug
In the ControlCatalog, if you open the previously collapsed side-menu and select an menu item, you cannot re-open the collapsed side-menu again.
To Reproduce
Steps to reproduce the behavior:
- Open ControlCatalog (Windows, Android,…)
- Reduce the width of the Window until the left side-menu collapses/hides (important!)
- Click the Hamburger button multiple times - the side-menu shows and hides as expected
- Now, open a menu item like “Calendar”
- Try to open the side-menu again
- The side-menu does not open anymore - you have to restart the app to select another page
Expected behavior
The side-menu should always open/close.
Desktop (please complete the following information):
- OS: Windows 11 22H2 (22621.1344)
- Version:
- Works on 11 Preview 5,
- Broken on current Master branch (92562b0d9979becc8d8c2316e1c2f0678bdae19d)
Investigation
The SplitView
’s IsPaneOpen
is bound by the Hamburger button.
SplitView.CoerceIsPaneOpen
should always get triggered when the Hamburger button (ToggleButton
) gets clicked. When it works, it is called for true
and false
. As soon as its broken, it’s only called when the value is true
.
Wild guess: As the side-menu already closes as soon as the menu-item is pressed (not released!), it seems as the mouse is captured in a weird way by the menu item or something.
Guilty Commit
80394d0097c4acc9b3b74024a863b97774c35d3e (but I think it’s an unhider as this changes IsPaneOpen
from DirectProperty
to StyledProperty
)
Maybe some issue with StyledProperty
?
Issue Analytics
- State:
- Created 7 months ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
In case it was the same as #10655, I had a look, and the issue here is: https://github.com/AvaloniaUI/Avalonia/blob/cbe0bb861a767b7bf7b268bbaa1d89dcf8523aea/samples/SampleControls/HamburgerMenu/HamburgerMenu.cs#L56-L62
Selecting an item with the SplitView display mode in
Overlay
results in settingIsPaneOpen
tofalse
with Animation priority - which is never reset so the pane can never be reopened as theHamburgerMenuButton
ToggleButton in the template is two-way bound to the SplitView@amwx Thanks for tracking that down!
The fix seems easy: use the brand-new SetCurrentValue() method that won’t destroy bindings and also won’t change binding priority or require setting as animation. Quick test seems to work OK, will open a PR to close.