[iOS 26] NavigationPage.TitleView resizing on iOS 26+ rotation - Fix#32815
[iOS 26] NavigationPage.TitleView resizing on iOS 26+ rotation - Fix#32815jfversluis merged 1 commit intodotnet:inflight/currentfrom
Conversation
Adds logic to update the TitleView frame during orientation changes for iOS 26+ and Mac Catalyst 26+, ensuring the TitleView expands to fill the navigation bar after rotation. Includes new test case and UI test to verify TitleView resizing behavior.
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where NavigationPage.TitleView does not properly resize when the device orientation changes on iOS 26+ and MacCatalyst 26+. The fix adds logic to update the TitleView frame during trait collection changes, ensuring it expands/contracts to match the navigation bar width after rotation.
Key Changes:
- Adds
TraitCollectionDidChangeoverride to detect orientation changes via size class transitions - Implements
UpdateTitleViewFrameForOrientationmethod to manually update TitleView frame for iOS 26+ - Includes comprehensive UI test to verify TitleView resizing behavior across rotations
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| NavigationRenderer.cs | Adds orientation change handling and frame update logic for iOS 26+ TitleView resizing |
| Issue32722.cs | Adds UI test to verify TitleView expands/contracts correctly during device rotation |
| Issue32722.xaml.cs | Creates test page with NavigationPage wrapper and Issue attribute |
| Issue32722.xaml | Defines test UI with TitleView containing visible Grid for measurement |
src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs
Show resolved
Hide resolved
| App.SetOrientationLandscape(); | ||
|
|
||
| // Wait for rotation to complete | ||
| System.Threading.Thread.Sleep(2000); |
There was a problem hiding this comment.
Using Thread.Sleep in tests is a brittle practice. Consider using a proper wait mechanism that checks for the condition to be met, or use the test framework's built-in wait utilities with a timeout. This would make the test more reliable and potentially faster.
| System.Threading.Thread.Sleep(2000); | ||
|
|
||
| // Verify TitleView returns to approximately original width | ||
| var titleViewFinal = App.WaitForElement("TitleViewGrid").GetRect(); | ||
| Assert.That(titleViewFinal.Width, Is.EqualTo(initialWidth).Within(5), | ||
| "TitleView should return to original width after rotating back"); | ||
| } |
There was a problem hiding this comment.
Using Thread.Sleep in tests is a brittle practice. Consider using a proper wait mechanism that checks for the condition to be met, or use the test framework's built-in wait utilities with a timeout. This would make the test more reliable and potentially faster.
| System.Threading.Thread.Sleep(2000); | |
| // Verify TitleView returns to approximately original width | |
| var titleViewFinal = App.WaitForElement("TitleViewGrid").GetRect(); | |
| Assert.That(titleViewFinal.Width, Is.EqualTo(initialWidth).Within(5), | |
| "TitleView should return to original width after rotating back"); | |
| } | |
| WaitForTitleViewWidth("TitleViewGrid", initialWidth, tolerance: 5, timeoutMs: 3000); | |
| // Verify TitleView returns to approximately original width | |
| var titleViewFinal = App.WaitForElement("TitleViewGrid").GetRect(); | |
| Assert.That(titleViewFinal.Width, Is.EqualTo(initialWidth).Within(5), | |
| "TitleView should return to original width after rotating back"); | |
| } | |
| /// <summary> | |
| /// Waits until the TitleView's width is within the specified tolerance of the expected value, or until timeout. | |
| /// </summary> | |
| private void WaitForTitleViewWidth(string automationId, double expectedWidth, double tolerance, int timeoutMs) | |
| { | |
| var start = DateTime.UtcNow; | |
| while ((DateTime.UtcNow - start).TotalMilliseconds < timeoutMs) | |
| { | |
| var rect = App.WaitForElement(automationId).GetRect(); | |
| if (Math.Abs(rect.Width - expectedWidth) <= tolerance) | |
| return; | |
| System.Threading.Thread.Sleep(100); | |
| } | |
| // Final check after timeout | |
| var finalRect = App.WaitForElement(automationId).GetRect(); | |
| if (Math.Abs(finalRect.Width - expectedWidth) > tolerance) | |
| { | |
| Assert.Fail($"TitleView width did not return to expected value within {timeoutMs}ms. Expected: {expectedWidth}, Actual: {finalRect.Width}"); | |
| } | |
| } |
Co-authored-by: kubaflo <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: kubaflo <42434498+kubaflo@users.noreply.github.com>
…rotation Co-authored-by: kubaflo <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: kubaflo <42434498+kubaflo@users.noreply.github.com>
Co-authored-by: kubaflo <42434498+kubaflo@users.noreply.github.com>
Final Code Review - PR #32815NavigationPage.TitleView Resizing on iOS 26+ RotationExecutive SummaryStatus: ✅ APPROVED FOR MERGE PR #32815 successfully fixes issue #32722 where NavigationPage.TitleView does not resize when device orientation changes on iOS 26+. The fix has been validated through comprehensive testing showing the bug is reproduced without the fix and resolved with the fix applied. Test Results (iOS 26+ Device Testing)✅ WITH PR Fix AppliedTest Outcome: PASSED ✅ Analysis: TitleView properly expands and contracts with orientation changes, matching the navigation bar width in each orientation. This is the expected and correct behavior. ❌ WITHOUT PR Fix (Baseline)Test Outcome: FAILED (Bug Reproduced) ❌ Analysis: TitleView width remains constant at ~375px despite orientation change. This confirms the bug exists without the fix - TitleView does not adjust to the new navigation bar width in landscape orientation. Code ReviewImplementation AnalysisFile: Changes Made:
Code Quality Assessment✅ Strengths:
✅ Best Practices:
No concerns identified - Implementation is solid and well-considered. Test Coverage AssessmentAutomated TestsFile: Coverage:
Manual Test CaseFile: Coverage:
Assessment: ✅ Excellent test coverage - Both automated and manual tests are well-designed and comprehensive. Technical BackgroundRoot CauseiOS 26 changed how autoresizing masks work for navigation bar title views. The autoresizing mask ( Why This Fix WorksBy overriding Platform Specificity
Validation Checklist
Risk AssessmentRisk Level: ✅ LOW Mitigations:
Potential Impacts:
Recommendation✅ APPROVE AND MERGEThis PR:
No blockers identified. Ready for merge. Related Issues
Testing CreditsSpecial thanks to @kubaflo for conducting the iOS 26+ device testing and validating both the bug reproduction and the fix. Review Date: 2025-11-24 |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 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!
Description of Change
Adds logic to update the TitleView frame during orientation changes for iOS 26+ and Mac Catalyst 26+, ensuring the TitleView expands to fill the navigation bar after rotation. Includes new test case and UI test to verify TitleView resizing behavior.
Issues Fixed
Fixes #32722
Screen.Recording.2025-11-23.at.17.03.41.mov
Screen.Recording.2025-11-23.at.16.57.06.mov