Skip to content

[iOS] Fix SearchBar unexpected left margin in iPad windowed mode on 26 Version#34704

Open
SubhikshaSf4851 wants to merge 7 commits intodotnet:mainfrom
SubhikshaSf4851:Fix-34551
Open

[iOS] Fix SearchBar unexpected left margin in iPad windowed mode on 26 Version#34704
SubhikshaSf4851 wants to merge 7 commits intodotnet:mainfrom
SubhikshaSf4851:Fix-34551

Conversation

@SubhikshaSf4851
Copy link
Copy Markdown
Contributor

@SubhikshaSf4851 SubhikshaSf4851 commented Mar 27, 2026

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). UISearchBar applies this via UIKit, 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:

  • Updated the MauiSearchBar constructor to set InsetsLayoutMarginsFromSafeArea = false, preventing UIKit from automatically applying safe-area insets and avoiding double-inset scenarios on iPadOS 26+ windowed mode.

Testing :

  • Added a new test, MauiSearchBarInsetsLayoutMarginsFromSafeAreaIsFalse, to verify that InsetsLayoutMarginsFromSafeArea is disabled on the MauiSearchBar, ensuring the fix remains in place.
  • Included the necessary 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

  • Windows
  • Android
  • iOS
  • Mac
Before Issue Fix After Issue Fix
BeforeFix34551.mov
AfterFix34551.mov

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 27, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34704

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34704"

@dotnet-policy-service dotnet-policy-service Bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Mar 27, 2026
@SubhikshaSf4851 SubhikshaSf4851 changed the title Fix SearchBar unexpected left margin in iPad windowed mode on 26 Version [iOS] Fix SearchBar unexpected left margin in iPad windowed mode on 26 Version Mar 27, 2026
@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Mar 28, 2026
@SubhikshaSf4851
Copy link
Copy Markdown
Contributor Author

🤖 AI Summary

📊 Expand Full Review97fab15 · updated condition only for iPad

As recommended I have moved the logics into MauiSearchBar also Added Device Test

@sheiksyedm sheiksyedm marked this pull request as ready for review March 30, 2026 10:16
Copilot AI review requested due to automatic review settings March 30, 2026 10:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = false for MauiSearchBar.
  • Add an iOS device test asserting MauiSearchBar.InsetsLayoutMarginsFromSafeArea is false.

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.

Comment thread src/Core/src/Platform/iOS/MauiSearchBar.cs Outdated
Copy link
Copy Markdown
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests failed

@SubhikshaSf4851
Copy link
Copy Markdown
Contributor Author

@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.

WithOut Fix With Fix
Screenshot 2026-04-06 at 11 44 00 Screenshot 2026-04-06 at 11 43 05
Device Test UI Test
Screenshot 2026-04-06 at 12 35 03 Screenshot 2026-04-06 at 12 28 39

@MauiBot MauiBot added the s/agent-fix-win AI found a better alternative fix than the PR label Apr 7, 2026
Copy link
Copy Markdown
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There'a an updated ai's summary - could you please check it?

@SubhikshaSf4851
Copy link
Copy Markdown
Contributor Author

@kubaflo I have implemented the suggested changes

@sheiksyedm
Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Copy Markdown
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The device tests are failing for iPhone 11

@SubhikshaSf4851
Copy link
Copy Markdown
Contributor Author

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.
Screenshot 2026-04-13 at 18 32 37

@dotnet dotnet deleted a comment from MauiBot Apr 14, 2026
@dotnet dotnet deleted a comment from MauiBot Apr 14, 2026
@sheiksyedm
Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests , maui-pr-devicetests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Copy Markdown
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please review the AI's suggestions?

@SubhikshaSf4851
Copy link
Copy Markdown
Contributor Author

@kubaflo I have updated the suggested changes ,

@dotnet dotnet deleted a comment from MauiBot Apr 17, 2026
@dotnet dotnet deleted a comment from MauiBot Apr 17, 2026
Copy link
Copy Markdown
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should scope it to iOS 26+ only?

@SubhikshaSf4851
Copy link
Copy Markdown
Contributor Author

@kubaflo Initially added a condition and limited the fix to version 26, but the AI summary suggested removing it. However, removing the condition did not change the behavior in version 18. so kept it as it is.

@dotnet dotnet deleted a comment from MauiBot Apr 21, 2026
@dotnet dotnet deleted a comment from MauiBot Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-controls-searchbar SearchBar control community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) version/iOS-26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

in iPad windowed mode SearchBar adds left margin equivaltent to SafeAreaInsets when placed inside grid

7 participants