-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[MacCatalyst] Fix TitleView not expanding to full size when maximizing the window #33763
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?
Conversation
|
Hey there @@KarthikRajaKalaimani! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/rebase |
…xtra spacing when window is maximized
bf91bac to
d1f640f
Compare
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 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.
Pull request overview
This pull request fixes a MacCatalyst-specific issue where a custom TitleView in NavigationPage does not expand to full width when the window is maximized. The fix ensures the TitleView frame is properly recalculated during window resize events by calling UpdateTitleViewFrameForOrientation() within the ViewWillTransitionToSize animation coordinator.
Changes:
- Added MacCatalyst-specific logic to update TitleView frame during window transitions
- Created UI tests to verify TitleView expansion behavior across platforms (window maximize on MacCatalyst/Windows, orientation change on iOS/Android)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs |
Added MacCatalyst-specific code to call UpdateTitleViewFrameForOrientation() during view size transitions, ensuring TitleView frame updates alongside transition animations |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33613.cs |
NUnit test that verifies TitleView width increases after window maximize/orientation change |
src/Controls/tests/TestCases.HostApp/Issues/XFIssue/Issue33613.cs |
HostApp UI test page with NavigationPage containing a custom TitleView that demonstrates the resize behavior |
| #if MACCATALYST || WINDOWS | ||
| App.EnterFullScreen(); | ||
| #elif ANDROID || IOS | ||
| App.SetOrientationLandscape(); | ||
| #endif |
Copilot
AI
Jan 30, 2026
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.
Platform-specific conditional logic is implemented using inline preprocessor directives in the test method, which violates the UI testing guidelines. The guidelines explicitly state "No Inline #if Directives in Test Methods" to maintain code readability and cleanliness.
Move this platform-specific logic into an extension method. For example, create a method like ResizeOrRotateWindow that encapsulates the platform-specific behavior for testing window size changes.
| #elif ANDROID || IOS | ||
| App.SetOrientationLandscape(); | ||
| #endif | ||
| Thread.Sleep(1000); // Wait for the animation to complete |
Copilot
AI
Jan 30, 2026
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.
Thread.Sleep is used here to wait for animation completion. According to the UI Testing Guidelines, there are better alternatives for handling animations and timing issues. The guidelines recommend:
- For animations: Use VerifyScreenshot with retryTimeout parameter instead of Thread.Sleep. For example:
VerifyScreenshot(retryTimeout: TimeSpan.FromSeconds(2))which will keep retrying until the animation completes. - For element readiness: Use WaitForElement with appropriate timeout.
The current pattern doesn't guarantee that the animation has actually completed - it just waits an arbitrary amount of time. Using retryTimeout would be more robust as it keeps retrying until the expected state is reached.
Issue Details:
The TitleView is not expanding to fullsize, when maximize the window in mac platform.
Root Cause:
The TitleView's frame is not recalculated when the navigation bar width changes, causing the layout to appear incorrect with stale positioning values in mac platform.
Description of Change:
I call the UpdateTitleViewFrameForOrientation() method from ViewWillTransitionToSize, which is the appropriate callback for MacCatalyst window resize events. This method runs alongside the transition coordinator’s animation, allowing the TitleView’s frame to be updated smoothly to match the new navigation bar dimensions.
Tested the behavior in the following platforms.
Reference:
N/A
Issues Fixed:
Fixes #33613
Screenshots
Screen.Recording.2026-01-29.at.12.10.45.PM.mov
Screen.Recording.2026-01-29.at.12.14.36.PM.mov