[iOS] Fix SearchBar unexpected left margin in iPad windowed mode on 26 Version#34704
[iOS] Fix SearchBar unexpected left margin in iPad windowed mode on 26 Version#34704SubhikshaSf4851 wants to merge 7 commits intodotnet:mainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34704Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34704" |
e30453e to
f97218d
Compare
As recommended I have moved the logics into MauiSearchBar also Added Device Test |
There was a problem hiding this comment.
Pull request overview
Fixes the extra left margin seen on iPadOS 26 in windowed mode by preventing UISearchBar from propagating safe-area insets into its layout margins (avoiding a double-inset when MAUI already applies safe area at the layout level).
Changes:
- Set
InsetsLayoutMarginsFromSafeArea = falseforMauiSearchBar. - Add an iOS device test asserting
MauiSearchBar.InsetsLayoutMarginsFromSafeAreaisfalse.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Core/src/Platform/iOS/MauiSearchBar.cs | Disables UIKit’s safe-area-to-layout-margins propagation on the native search bar. |
| src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.iOS.cs | Adds a regression test asserting the new default value for InsetsLayoutMarginsFromSafeArea. |
|
@kubaflo I have checked the device tests and UI tests in local which contains category searchBar and no test were failed. I have also checked the test for issue34551, It fails without Fix and passed with Fix.
|
kubaflo
left a comment
There was a problem hiding this comment.
There'a an updated ai's summary - could you please check it?
|
@kubaflo I have implemented the suggested changes |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
kubaflo
left a comment
There was a problem hiding this comment.
The device tests are failing for iPhone 11
@kubaflo I have checked the test in local iphone 11 simulator in 18 and 26 version. No failures were observed. Also i have checked in device test which contains category SearchBar in iOS, Also no failure were observed. |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
kubaflo
left a comment
There was a problem hiding this comment.
Could you please review the AI's suggestions?
|
@kubaflo I have updated the suggested changes , |
kubaflo
left a comment
There was a problem hiding this comment.
Maybe we should scope it to iOS 26+ only?





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 whether this change resolves your issue. Thank you!
Root Cause :
iPadOS 26 windowed mode introduces a left safe-area inset (due to traffic light buttons).
UISearchBarapplies this viaUIKit, and MAUI also applies safe area at the layout level. Both together cause a double inset, resulting in an extra left margin.Description of Change :
Safe Area Handling Fix:
MauiSearchBarconstructor to setInsetsLayoutMarginsFromSafeArea = false, preventing UIKit from automatically applying safe-area insets and avoiding double-inset scenarios on iPadOS 26+ windowed mode.Testing :
MauiSearchBarInsetsLayoutMarginsFromSafeAreaIsFalse, to verify thatInsetsLayoutMarginsFromSafeAreais disabled on theMauiSearchBar, ensuring the fix remains in place.using Microsoft.Maui.Platform;directive in the test file to support the new test.Issues Fixed
Fixes #34551
Tested the behavior in the following platforms
BeforeFix34551.mov
AfterFix34551.mov