-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows, Catalyst] Fix IsPresented=true Not Working on Initial Value in FlyoutPage #31515
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
base: main
Are you sure you want to change the base?
[Windows, Catalyst] Fix IsPresented=true Not Working on Initial Value in FlyoutPage #31515
Conversation
Hey there @@devanathan-vaithiyanathan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where setting IsPresented="true"
on a FlyoutPage doesn't open the flyout automatically on app launch for Windows and macOS Catalyst platforms. The fix addresses timing issues where platform views are loaded before XAML properties are applied.
- Delays frame observer connection on macOS Catalyst using DispatchQueue to ensure XAML properties load first
- Adds a Loaded event handler on Windows to apply IsPresented value after platform view is ready
- Includes comprehensive UI tests to validate the fix
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/Core/src/Handlers/Window/WindowHandler.iOS.cs |
Conditionally delays frame observer connection for macOS Catalyst using DispatchQueue |
src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Windows.cs |
Adds Loaded event handler to apply IsPresented value after platform view initialization |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31372.cs |
NUnit test to verify flyout is presented on initial load |
src/Controls/tests/TestCases.HostApp/Issues/Issue31372.cs |
UI test page demonstrating FlyoutPage with IsPresented=true |
void OnLoaded(object sender, RoutedEventArgs e) | ||
{ | ||
if (VirtualView is not null) | ||
{ | ||
PlatformView.IsPaneOpen = VirtualView.IsPresented; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OnLoaded event handler will fire every time the control is loaded, but the IsPresented synchronization only needs to happen once. Consider unsubscribing from the Loaded event after the first execution to avoid unnecessary repeated executions.
Copilot uses AI. Check for mistakes.
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
if (!_intialLayoutFinished) | ||
{ | ||
_intialLayoutFinished = true; | ||
SetInitialPresented(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ViewDidAppear()
is much later in the lifecycle. Not a problem, but this could cause a visible delay where the flyout opens after the user sees the page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devanathan-vaithiyanathan if you do it via IUIViewLifeCycleEvents does ethat cause less delay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PureWeen , PhoneFlyoutPageRenderer is derived from UIViewController, not UIView. Therefore, overriding MovedToWindow isn’t possible, and invoking the MovedToWindow event handler isn’t applicable in this case.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the changes to this file
You can fix this by adding a REMOVE inside the unshipped
or you can use the cake script for this locally
dotnet cake --target=publicapi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PureWeen , Thanks for the suggestion. I’ve moved the changes from Shipped to Unshipped.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Details
When setting IsPresented="True" on a FlyoutPage in .NET MAUI , the flyout does not open automatically on app launch as expected.
Description of Change
On macOS, the frame observer connection is delayed using DispatchQueue.MainQueue.DispatchAsync() so XAML properties finish loading before observation starts.
On Windows, PlatformView is loaded before applying the IsPresented value.
Issues Fixed
Fixes #31372
Tested the behavior in the following platforms.