-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WinUI] Flyout Popover doesn't reset "IsPresented" when dismissed via click on contents. #13496
Comments
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
I just ran into this. I have a workaround that monitors using System.ComponentModel;
namespace FunctionZero.Maui.MvvmZero.Workaround
{
public class AdaptedFlyoutPage : FlyoutPage
{
Page _oldFlyout;
public AdaptedFlyoutPage()
{
#if WINDOWS
PropertyChanged += AdaptedFlyoutPage_PropertyChanged;
#endif
_oldFlyout = null;
}
private void AdaptedFlyoutPage_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(FlyoutPage.Flyout))
{
if (_oldFlyout != null)
_oldFlyout.PropertyChanged -= FlyoutFlyout_PropertyChanged;
if (Flyout != null)
Flyout.PropertyChanged += FlyoutFlyout_PropertyChanged;
_oldFlyout = Flyout;
}
}
private async void FlyoutFlyout_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Page.IsFocused))
{
if (FlyoutLayoutBehavior == FlyoutLayoutBehavior.Popover)
{
if (Flyout.IsFocused == false)
{
// Delay is necessary otherwise closing the Flyout using the hamburger menu
// immediately repoens it, for no sane reason.
await Task.Delay(120);
IsPresented = false;
}
}
}
}
}
} |
@drasticactions I see you suggested a workaround ...
Do you know how to detect the flyout closing? (Other than watching |
You could directly subscribe to each the |
fwiw, seems to me a more simple description of this bug is
Seems to me such a fundamental and simple problem that should be addressed. Surprised to see it go straight to the back burner |
I think this is a much more straightforward work around for the this issue. #if WINDOWS
PropertyChanged += (_, propertyChangedEventHandler) =>
{
if (propertyChangedEventHandler.PropertyName == nameof(FlyoutLayoutBehavior) && FlyoutLayoutBehavior is not (FlyoutLayoutBehavior.Popover or FlyoutLayoutBehavior.SplitOnPortrait))
IsPresented = true;
};
Flyout.Focused += (_, __) =>
{
if (FlyoutLayoutBehavior is FlyoutLayoutBehavior.Popover or FlyoutLayoutBehavior.SplitOnPortrait)
IsPresented = true;
};
Flyout.Unfocused += (_, __) =>
{
if (FlyoutLayoutBehavior is FlyoutLayoutBehavior.Popover or FlyoutLayoutBehavior.SplitOnPortrait)
IsPresented = false;
};
#endif The suggestion above ignores the |
Verified this issue with Visual Studio Enterprise 17.9.0 Preview 1.0. Can repro on windows platform. |
Is this planning to be fixed any sooner ? |
When should we Unsubscribe to these event in deconstructor ? or when handler is changing to null ?.In Case user logged out and we are setting MainPage to login screen |
@SarthakB26 frankly Ive found further issues with this solution. So now i do something like this, another workaround hack:
The above is also brittle because depending if you resize a window from large to small, or small to large, there are different sizes to which the Honestly Im not worried about unsubscribing as the page lasts the lifetime of the application. |
I used the native control event of the MainPage/FlyoutPage (NavigationView in WinUI) to trigger resetting of IsPresented (tested for Popover behavior):
|
Description
When using a Popover FlyoutPage on WinUI and setting "IsPresented", the Flyout pane will show. Clicking on the main page contents will hide the popover, but "IsPresented" is still true, meaning you can't reinvoke the popover again unless you set it to false yourself.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/dotnet/maui/blob/main/src/Controls/samples/Controls.Sample
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
At least WinUI, may affect other platforms.
Did you find any workaround?
Detect when the flyout is closing and handle "IsPresenting" yourself, but this may cause the flyout to close twice.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: