Skip to content

[iOS&Mac] Fix Shell SearchHandler Query update on Initial load#35008

Merged
kubaflo merged 3 commits into
dotnet:inflight/currentfrom
SubhikshaSf4851:Fix-iOS-SearchHandler-Query-InitialLoad
Apr 27, 2026
Merged

[iOS&Mac] Fix Shell SearchHandler Query update on Initial load#35008
kubaflo merged 3 commits into
dotnet:inflight/currentfrom
SubhikshaSf4851:Fix-iOS-SearchHandler-Query-InitialLoad

Conversation

@SubhikshaSf4851

Copy link
Copy Markdown
Contributor

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!

This pull request addresses an issue where the SearchHandler.Query value was not displayed in the search bar on iOS and MacCatalyst at load time. The fix ensures that the initial query value is shown as expected, and includes new test coverage to prevent regressions.

Description of Change

Bug fix:

  • Ensured that the search bar's text is set to the SearchHandler.Query value when attaching the search controller in ShellPageRendererTracker.cs, so the initial query is visible on iOS/MacCatalyst.

Testing improvements:

  • Added an automated UI test (Issue35005) to verify that the SearchHandler.Query value is visible in the search bar on page load across all platforms.
  • Introduced a new test case page (Issue35005) in the sample app to facilitate manual and automated testing of this scenario.

Issues Fixed

Fixes #35005

Tested the behavior in the following platforms

  • Windows
  • Android
  • iOS
  • Mac
Before Issue Fix After Issue Fix
iOSQuerySetonInitialLoadBeforeFix Simulator Screenshot - iPhone Xs - 2026-04-17 at 16 05 47

@github-actions

Copy link
Copy Markdown
Contributor

🚀 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 -- 35008

Or

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

@MauiBot

MauiBot commented Apr 26, 2026

Copy link
Copy Markdown
Collaborator

🤖 AI Summary

👋 @SubhikshaSf4851 — new AI review results are available. Please review the latest session below.

📊 Review Sessionb723116 · Test Sample updated. · 2026-04-26 12:28 UTC
🚦 Gate — Test Before & After Fix

Test Verification Report

Date: 2026-04-26 04:25:25 | Platform: CATALYST | Status: ✅ PASSED

Summary

Check Expected Actual Result
Tests WITHOUT fix FAIL FAIL
Tests WITH fix PASS PASS

✅ Final Verdict

VERIFICATION PASSED

The tests correctly detect the issue:

  • ✅ Tests FAIL without the fix (as expected - bug is present)
  • ✅ Tests PASS with the fix (as expected - bug is fixed)

Conclusion: The tests properly validate the fix and catch the bug when it's present.


Configuration

Platform: catalyst
Test Filter: Issue35005
Base Branch: main
Merge Base: d5e39b0

Fix Files

  • src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs

Test Results Details

Test Run 1: WITHOUT Fix

Expected: Tests should FAIL (bug is present)
Actual: Tests FAILED ✅

View full test output (without fix)
  Determining projects to restore...
  Restored /Users/cloudtest/vss/_work/1/s/src/Graphics/src/Graphics/Graphics.csproj (in 700 ms).
  Restored /Users/cloudtest/vss/_work/1/s/src/Essentials/src/Essentials.csproj (in 4.67 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/Core/Controls.Core.csproj (in 5.16 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/src/Xaml/Controls.Xaml.csproj (in 5.16 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/BlazorWebView/src/Maui/Microsoft.AspNetCore.Components.WebView.Maui.csproj (in 5.16 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Core/maps/src/Maps.csproj (in 5.16 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Core/src/Core.csproj (in 5.16 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/Maps/src/Controls.Maps.csproj (in 5.16 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/Foldable/src/Controls.Foldable.csproj (in 5.17 sec).
  Restored /Users/cloudtest/vss/_work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj (in 5.29 sec).
  1 of 11 projects are up-to-date for restore.
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Graphics -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Graphics/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Essentials -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Essentials/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Core/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.dll
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Maps -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Maps/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Maps.dll
  Controls.BindingSourceGen -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.BindingSourceGen/Debug/netstandard2.0/Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Controls.Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Core/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Controls.dll
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Controls.Maps -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Maps/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Controls.Maps.dll
  Controls.Xaml -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Xaml/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Controls.Xaml.dll
  Microsoft.AspNetCore.Components.WebView.Maui -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Microsoft.AspNetCore.Components.WebView.Maui/Debug/net10.0-maccatalyst26.0/Microsoft.AspNetCore.Components.WebView.Maui.dll
  Controls.Foldable -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Foldable/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Controls.Foldable.dll
  Detected signing identity:
    Code Signing Key: "" (-)
    Provisioning Profile: "" () - no entitlements
    Bundle Id: com.microsoft.maui.uitests
    App Id: com.microsoft.maui.uitests
  Detected signing identity:
    Code Signing Key: "" (-)
    Provisioning Profile: "" () - no entitlements
    Bundle Id: com.microsoft.maui.uitests
    App Id: com.microsoft.maui.uitests
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Controls.TestCases.HostApp -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.HostApp/Debug/net10.0-maccatalyst/maccatalyst-x64/Controls.TestCases.HostApp.dll
  Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Optimizing assemblies for size. This process might take a while.
  Detected signing identity:
    Code Signing Key: "" (-)
    Provisioning Profile: "" () - no entitlements
    Bundle Id: com.microsoft.maui.uitests
    App Id: com.microsoft.maui.uitests
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Controls.TestCases.HostApp -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.HostApp/Debug/net10.0-maccatalyst/maccatalyst-arm64/Controls.TestCases.HostApp.dll
  Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Optimizing assemblies for size. This process might take a while.

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:01:16.34


Test Run 2: WITH Fix

Expected: Tests should PASS (bug is fixed)
Actual: Tests PASSED ✅

View full test output (with fix)
  Determining projects to restore...
  All projects are up-to-date for restore.
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Graphics -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Graphics/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Graphics.dll
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Essentials -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Essentials/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Essentials.dll
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Core/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.dll
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Maps -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Maps/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Maps.dll
  Controls.BindingSourceGen -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.BindingSourceGen/Debug/netstandard2.0/Microsoft.Maui.Controls.BindingSourceGen.dll
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Controls.Core -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Core/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Controls.dll
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Controls.Foldable -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Foldable/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Controls.Foldable.dll
  Controls.Xaml -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Xaml/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Controls.Xaml.dll
  Microsoft.AspNetCore.Components.WebView.Maui -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Microsoft.AspNetCore.Components.WebView.Maui/Debug/net10.0-maccatalyst26.0/Microsoft.AspNetCore.Components.WebView.Maui.dll
  Controls.Maps -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.Maps/Debug/net10.0-maccatalyst26.0/Microsoft.Maui.Controls.Maps.dll
  Detected signing identity:
    Code Signing Key: "" (-)
    Provisioning Profile: "" () - no entitlements
    Bundle Id: com.microsoft.maui.uitests
    App Id: com.microsoft.maui.uitests
  Detected signing identity:
    Code Signing Key: "" (-)
    Provisioning Profile: "" () - no entitlements
    Bundle Id: com.microsoft.maui.uitests
    App Id: com.microsoft.maui.uitests
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Controls.TestCases.HostApp -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.HostApp/Debug/net10.0-maccatalyst/maccatalyst-x64/Controls.TestCases.HostApp.dll
  Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Optimizing assemblies for size. This process might take a while.
  Detected signing identity:
    Code Signing Key: "" (-)
    Provisioning Profile: "" () - no entitlements
    Bundle Id: com.microsoft.maui.uitests
    App Id: com.microsoft.maui.uitests
  ##vso[build.updatebuildnumber]10.0.70-ci+azdo.13940074
  Controls.TestCases.HostApp -> /Users/cloudtest/vss/_work/1/s/artifacts/bin/Controls.TestCases.HostApp/Debug/net10.0-maccatalyst/maccatalyst-arm64/Controls.TestCases.HostApp.dll
  Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Optimizing assemblies for size. This process might take a while.

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:01:17.31


Logs

  • Full verification log: /Users/cloudtest/vss/_work/1/s/CustomAgentLogsTmp/PRState/35008/PRAgent/gate/verify-tests-fail/verification-log.txt
  • Test output without fix: /Users/cloudtest/vss/_work/1/s/CustomAgentLogsTmp/PRState/35008/PRAgent/gate/verify-tests-fail/test-without-fix.log
  • Test output with fix: /Users/cloudtest/vss/_work/1/s/CustomAgentLogsTmp/PRState/35008/PRAgent/gate/verify-tests-fail/test-with-fix.log
  • UI test logs: CustomAgentLogsTmp/UITests/

🧪 UI Tests — Category Detection

Detected UI test categories: Shell


🔍 Pre-Flight — Context & Validation

Issue: #35005 - [iOS&Mac] Shell SearchHandler Query not shown in search bar on initial load
PR: #35008 - [iOS&Mac] Fix Shell SearchHandler Query update on Initial load
Platforms Affected: iOS, macCatalyst
Files Changed: 1 implementation, 2 test

Key Findings

  • Root cause: AttachSearchController() in ShellPageRendererTracker.cs initialized searchBar.Placeholder but not searchBar.Text, so any Query set before page load was silently discarded
  • Fix: one-line addition searchBar.Text = SearchHandler.Query; right after searchBar.Placeholder = SearchHandler.Placeholder; in AttachSearchController()
  • Android is not affected (already sets Text during initialization in ShellSearchView.cs)
  • Windows: unknown – not tested by author (PR in draft), unrestricted UI test will run there
  • Re-navigation safety: AttachSearchController() is called on every SearchHandler re-set (tab switch), so fix is idempotent
  • No feedback loop: UIKit does not fire UISearchResultsUpdating when UISearchBar.Text is set programmatically

Code Review Summary

Verdict: NEEDS_DISCUSSION
Confidence: high
Errors: 0 | Warnings: 2 | Suggestions: 1

Key code review findings:

  • ⚠️ src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35005.cs — Test runs on all platforms including Windows, but Windows device tests weren't verified; could fail if Windows has the same bug
  • ⚠️ PR is still in draft; maui-pr-devicetests CI has not run; device-test confirmation needed before merge
  • 💡 src/Controls/tests/TestCases.HostApp/Issues/Issue35005.cs:3PlatformAffected.iOS should also include macOS (fix applies to MacCatalyst too)

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #35008 Set searchBar.Text = SearchHandler.Query in AttachSearchController() ✅ PASSED (Gate) ShellPageRendererTracker.cs Original PR

🔬 Code Review — Deep Analysis

Code Review — PR #35008

Independent Assessment

What this changes: Adds a single line searchBar.Text = SearchHandler.Query; in AttachSearchController() in ShellPageRendererTracker.cs, alongside the existing searchBar.Placeholder = SearchHandler.Placeholder; assignment. Adds a HostApp page and a UI test that verifies the pre-set query value appears in the search bar on page load.

Inferred motivation: The UISearchBar was initialized with the Placeholder but not the initial Query value, so any Query set before the page loaded would be silently lost.


Reconciliation with PR Narrative

Author claims: Bug fix for SearchHandler.Query not displayed on iOS/MacCatalyst at load time; includes new UI test coverage; tested on iOS and Mac only (Windows/Android unchecked, PR is draft).

Agreement: Assessment matches the author's description. The fix location and approach are correct. Android sets the initial query text already (line 197 in ShellSearchView.cs), which is consistent with Android not being listed as affected.

Discrepancy: The PlatformAffected.iOS in the [Issue] attribute on the HostApp page should include macOS since the fix applies to MacCatalyst (this file lives in the iOS compatibility layer but compiles for both). Minor metadata issue only.


Findings

⚠️ Warning — UI test has no platform restriction, but Windows hasn't been verified

File: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35005.cs

The test will run on all platforms (Android, iOS, MacCatalyst, Windows) since there's no [Category(UITestCategories.IsNotRunningOnXxx)] guard. This is correct per MAUI convention ("UI tests must run on all applicable platforms"). However, Windows was unchecked in the PR's test matrix, and GetShellSearchHandler() on Windows uses app.WaitForElement("TextBox") which relies on finding the Shell search TextBox by class name. If the Shell SearchHandler on Windows does not pre-populate Query at initial load (the same class of bug), this test will fail on Windows device tests.

Android has been verified safe: ShellSearchView.cs:197 already sets Text = query during initialization.

Recommendation: Before removing the draft status, run Windows device tests or add a code comment explaining why Windows passes. If Windows also has this bug, a separate fix in the Windows Shell handler is needed.


⚠️ Warning — Device tests not yet triggered (PR is draft)

The maui-pr build CI is green, but maui-pr-devicetests has not run. Since the fix is in iOS/macCatalyst rendering code and the primary verification is a UI test, device test CI should pass before merge. The PR should be marked ready-for-review only after device tests are confirmed green.


💡 Suggestion — PlatformAffected.iOS is incomplete for MacCatalyst

File: src/Controls/tests/TestCases.HostApp/Issues/Issue35005.cs:3

[Issue(IssueTracker.Github, 35005, "...", PlatformAffected.iOS)]

The fix applies to MacCatalyst as well (same ShellPageRendererTracker.cs is used). The annotation should be:

[Issue(IssueTracker.Github, 35005, "...", PlatformAffected.iOS | PlatformAffected.macOS)]

PlatformAffected is metadata only and doesn't affect test execution, but accuracy helps future triage.


Devil's Advocate

"Is there a side effect from setting searchBar.Text programmatically?"

In UIKit, programmatically setting UISearchBar.Text does not trigger UISearchResultsUpdating.UpdateSearchResultsForSearchController, so the SetSearchResultsUpdater callback (which writes back to SearchHandler.QueryProperty) will not fire. No feedback loop risk.

"Does the fix break re-navigation scenarios?"

Shell re-creates the search controller on tab switch by calling AttachSearchController() again after DettachSearchController(). At that point SearchHandler.Query reflects the current value, so re-attaching with searchBar.Text = SearchHandler.Query is correct and idempotent.

"Is there a missing handler for Query property changes after initial load?"

OnSearchHandlerPropertyChanged does not handle QueryProperty — if a binding changes Query after the page is shown, the search bar won't update. This is a pre-existing gap in the iOS implementation (not introduced here) and is out of scope for this PR.

"Could this regress anything?"

The change is strictly additive — one line setting a native property that was previously unset. It cannot break the existing query-empty case (native UISearchBar defaults Text to empty string, so if Query is null or "", the result is the same as before).


Verdict: NEEDS_DISCUSSION

Confidence: high

Summary: The one-line fix is correct, minimal, and in exactly the right place. The adjacent code already initializes Placeholder and icons at the same location, making this a natural and safe change. The two discussion points are: (1) Windows device test coverage is absent — the unrestricted test will run on Windows and may fail if Windows has the same bug, and (2) the PR should not leave draft status until maui-pr-devicetests CI has been run and confirmed green on iOS/MacCatalyst.


🔧 Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (claude-opus-4.6) Added UpdateSearchBarQuery() helper; called from AttachSearchController() AND OnSearchHandlerPropertyChanged for QueryProperty ✅ PASS 1 file Also fixes pre-existing runtime Query-change gap; follows existing UpdateXxx() pattern
2 try-fix (claude-sonnet-4.6) Set text in SearchHandlerAppearanceTracker constructor ❌ FAIL 1 file MacCatalyst layout pass resets text after tracker initialization
3 try-fix (gpt-5.3-codex) Moved searchBar.Text assignment to immediately after UISearchController creation (before nav bar attachment) ✅ PASS 1 file Minor timing variation on same approach as PR; no additional benefits
4 try-fix (gpt-5.4) Deferred BeginInvokeOnMainThread from SetAppeared() ❌ FAIL 1 file Post-appear writes do not work on MacCatalyst
PR PR #35008 Inline searchBar.Text = SearchHandler.Query; after searchBar.Placeholder in AttachSearchController() ✅ PASSED (Gate) 1 file Original PR — minimal, correct placement

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 2 No NO NEW IDEAS
gpt-5.3-codex 2 No NO NEW IDEAS

Exhausted: Yes
Selected Fix: Candidate #1 (try-fix attempt 1) — UpdateSearchBarQuery() helper pattern is architecturally superior as it follows the existing codebase conventions, addresses the initial load bug, AND closes the pre-existing runtime Query-change gap in OnSearchHandlerPropertyChanged. Both Candidate #1 and the PR's fix are correct; Candidate #1 is more complete.


📋 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Issue #35005 — iOS/macCatalyst SearchHandler.Query not shown on initial load
Code Review NEEDS_DISCUSSION (high) 0 errors, 2 warnings, 1 suggestion
Gate ✅ PASSED maccatalyst
Try-Fix ✅ COMPLETE 4 attempts, 2 passing
Report ✅ COMPLETE

Code Review Impact on Try-Fix

The code review flagged a pre-existing gap: OnSearchHandlerPropertyChanged does not handle QueryProperty, so programmatic Query changes after initial load aren't synced to the search bar. Attempt 1 (✅ PASS) directly addressed this by adding a UpdateSearchBarQuery() helper wired into both AttachSearchController() and OnSearchHandlerPropertyChanged. This produced a broader, architecturally cleaner fix than the PR's inline approach. Attempt 2 (❌ FAIL) confirmed the code review insight about MacCatalyst's timing sensitivity — text must be set before SearchHandlerAppearanceTracker construction.

Summary

The PR fixes a real and verified bug: on iOS/macCatalyst, SearchHandler.Query set before page load was not displayed in the native UISearchBar because AttachSearchController() initialized searchBar.Placeholder but forgot searchBar.Text. The one-line fix is correct and minimal. However, Try-Fix exploration found a better alternative (Candidate #1) that also closes a pre-existing gap where runtime Query changes after initial load are not reflected in the search bar. The PR should adopt the UpdateSearchBarQuery() pattern. Additionally, two code review warnings should be addressed before removing draft status: (1) Windows device test coverage is unverified, and (2) device tests haven't run on the PR.

Root Cause

AttachSearchController() in ShellPageRendererTracker.cs set searchBar.Placeholder = SearchHandler.Placeholder but never set searchBar.Text = SearchHandler.Query. The UISearchBar was created with no text, discarding the initial query value. Android does not have this bug because ShellSearchView.cs already initializes Text during setup.

Fix Quality

The PR's fix is correct for the reported bug. However, the Try-Fix phase found a stronger alternative: adding a UpdateSearchBarQuery() helper method (following the existing UpdateSearchIsEnabled/UpdateSearchVisibility pattern) and calling it from both AttachSearchController() and OnSearchHandlerPropertyChanged (for QueryProperty). This broadens the fix to also handle the pre-existing gap where programmatic Query changes after load aren't reflected in the search bar. The PR should adopt this pattern.

Additionally:

  • [Issue(..., PlatformAffected.iOS)] should be PlatformAffected.iOS | PlatformAffected.macOS to accurately reflect MacCatalyst impact
  • Windows device tests should be verified before merge (the test runs on all platforms, and Windows behavior is unconfirmed)
  • PR should be taken out of draft only after maui-pr-devicetests CI confirms green on iOS/macCatalyst

@MauiBot MauiBot added 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) labels Apr 26, 2026
@SubhikshaSf4851

Copy link
Copy Markdown
Contributor Author

🤖 AI Summary

👋 @SubhikshaSf4851 — new AI review results are available. Please review the latest session below.

📊 Review Sessionb723116 · Test Sample updated. · 2026-04-26 12:28 UTC
🚦 Gate — Test Before & After Fix

Test Verification Report

Date: 2026-04-26 04:25:25 | Platform: CATALYST | Status: ✅ PASSED

Summary

Check Expected Actual Result
Tests WITHOUT fix FAIL FAIL ✅
Tests WITH fix PASS PASS ✅

✅ Final Verdict

VERIFICATION PASSED

The selected fix is from Attempt 1, which also handles runtime query updates. However, this scenario was already evaluated and rejected due to flickering issues when updating dynamically.

Open issue for dynamic query changes: #14497

@sheiksyedm sheiksyedm marked this pull request as ready for review April 27, 2026 06:53
Copilot AI review requested due to automatic review settings April 27, 2026 06:53
@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).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Shell SearchHandler regression on iOS/MacCatalyst where a pre-set SearchHandler.Query wasn’t reflected in the native search UI on initial load, and adds an Appium UI test to prevent regressions.

Changes:

  • Set the native iOS UISearchBar.Text from SearchHandler.Query when attaching the search controller.
  • Added a HostApp issue page (Issue35005) that pre-sets SearchHandler.Query on load for manual + automated verification.
  • Added an Appium-based NUnit UI test to assert the initial query text is visible on load.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs Initializes UISearchBar.Text from SearchHandler.Query during search controller attachment.
src/Controls/tests/TestCases.HostApp/Issues/Issue35005.cs New repro page that sets SearchHandler.Query at startup.
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35005.cs New UI test asserting the initial query is visible in the Shell search field.

@@ -0,0 +1,46 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 35005, "SearchHandler Query not shown on iOS/MacCatalyst at load time", PlatformAffected.iOS)]

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

The Issue attribute says this affects only iOS (PlatformAffected.iOS), but the title/PR indicate iOS + MacCatalyst. Please update the PlatformAffected flags to include macOS/MacCatalyst (e.g., PlatformAffected.iOS | PlatformAffected.macOS) so the metadata matches the actual affected platforms.

Suggested change
[Issue(IssueTracker.Github, 35005, "SearchHandler Query not shown on iOS/MacCatalyst at load time", PlatformAffected.iOS)]
[Issue(IssueTracker.Github, 35005, "SearchHandler Query not shown on iOS/MacCatalyst at load time", PlatformAffected.iOS | PlatformAffected.macOS)]

Copilot uses AI. Check for mistakes.
@kubaflo kubaflo changed the base branch from main to inflight/current April 27, 2026 15:03
@kubaflo kubaflo merged commit 36fcf5d into dotnet:inflight/current Apr 27, 2026
156 of 168 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR7 milestone Apr 27, 2026
PureWeen pushed a commit that referenced this pull request Apr 28, 2026
<!-- Please keep the note below for people who find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses an issue where the `SearchHandler.Query`
value was not displayed in the search bar on iOS and MacCatalyst at load
time. The fix ensures that the initial query value is shown as expected,
and includes new test coverage to prevent regressions.
### Description of Change
**Bug fix:**

* Ensured that the search bar's text is set to the `SearchHandler.Query`
value when attaching the search controller in
`ShellPageRendererTracker.cs`, so the initial query is visible on
iOS/MacCatalyst.

**Testing improvements:**

* Added an automated UI test (`Issue35005`) to verify that the
`SearchHandler.Query` value is visible in the search bar on page load
across all platforms.
* Introduced a new test case page (`Issue35005`) in the sample app to
facilitate manual and automated testing of this scenario.

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #35005 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="1125" height="2436"
alt="iOSQuerySetonInitialLoadBeforeFix"
src="https://github.com/user-attachments/assets/a37f23f4-c02b-4fe1-8c52-5b01a6c3aa11"
/> | <img width="1125" height="2436" alt="Simulator Screenshot - iPhone
Xs - 2026-04-17 at 16 05 47"
src="https://github.com/user-attachments/assets/b3db5f83-4ebd-4cd3-8b67-3d8945fb7873"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
PureWeen pushed a commit that referenced this pull request Apr 29, 2026
<!-- Please keep the note below for people who find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses an issue where the `SearchHandler.Query`
value was not displayed in the search bar on iOS and MacCatalyst at load
time. The fix ensures that the initial query value is shown as expected,
and includes new test coverage to prevent regressions.
### Description of Change
**Bug fix:**

* Ensured that the search bar's text is set to the `SearchHandler.Query`
value when attaching the search controller in
`ShellPageRendererTracker.cs`, so the initial query is visible on
iOS/MacCatalyst.

**Testing improvements:**

* Added an automated UI test (`Issue35005`) to verify that the
`SearchHandler.Query` value is visible in the search bar on page load
across all platforms.
* Introduced a new test case page (`Issue35005`) in the sample app to
facilitate manual and automated testing of this scenario.

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #35005 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="1125" height="2436"
alt="iOSQuerySetonInitialLoadBeforeFix"
src="https://github.com/user-attachments/assets/a37f23f4-c02b-4fe1-8c52-5b01a6c3aa11"
/> | <img width="1125" height="2436" alt="Simulator Screenshot - iPhone
Xs - 2026-04-17 at 16 05 47"
src="https://github.com/user-attachments/assets/b3db5f83-4ebd-4cd3-8b67-3d8945fb7873"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
PureWeen pushed a commit that referenced this pull request Apr 30, 2026
…ability (#35133)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

> **Depends on #35136** (pipeline category detection — should merge
first)

## What this does

Two things:

### 1. UI test category detection in PR review

During the PR review workflow, Step 0.5 detects which UI test categories
the PR impacts and writes the result to the AI summary comment. This
gives reviewers visibility into which UI tests are relevant.

**Detection** reuses the 3-tier script from #35136 (test attributes →
source paths → AI reasoning).

**AI summary** shows a new 🧪 UI Tests section with detected categories
before the gate section.

### 2. Gate reliability fixes

Multiple fixes to make the gate (`verify-tests-fail.ps1`) more
deterministic:

| Fix | Problem it solves |
|-----|-------------------|
| **Absolute path resolution** | Gate scripts not found on Linux CI
agents (`Resolve-Path`, `GetFullPath`) |
| **File existence check** | Instant cryptic failure when verify script
is missing — now logs clear error |
| **3x retry on ENV ERROR** | Emulator timeouts, ADB failures, app
crashes — transient issues that pass on retry |
| **Strip bad report blocks** | Old verify script produces `Passed:
False` with empty counts — stripped instead of shown |
| **Gate log in fallback** | When report is missing, shows last 20 lines
of gate output instead of just `❌ FAILED / Platform: IOS` |

## Files

| File | Changes |
|------|---------|
| `.github/scripts/Review-PR.ps1` | Step 0.5 category detection + all 5
gate fixes |
| `.github/scripts/post-ai-summary-comment.ps1` | Add `uitests` phase to
render detected categories |
| `.github/pr-review/pr-preflight.md` | Step 7: AI identifies impacted
UI test categories |

## Validation — PR reviewer builds (Apr 26)

10 builds against real PRs — all succeeded ✅. Category detection shown
in AI summary comment.

| PR | Categories Detected | Build | AI Summary |
|----|-------------------|-------|------------|
| #35037 (WebView theme) | `ViewBaseTests,WebView` |
[13940071](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940071)
|
[comment](#35037 (comment))
|
| #35031 (Shell memory leak) | `Shell` |
[13940072](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940072)
|
[comment](#35031 (comment))
|
| #35020 (XAML Hot Reload) | _(none — XAML only)_ |
[13940073](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940073)
| ✅ Shows "No UI test categories" |
| #35008 (Shell SearchHandler) | `Shell` |
[13940074](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940074)
| ✅ |
| #34997 (RadioButton gradient) | `RadioButton,ViewBaseTests` |
[13940075](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940075)
| ✅ |
| #34980 (DatePicker rotation) | `ViewBaseTests` |
[13940076](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940076)
| ✅ |
| #34974 (Picker CharacterSpacing) | `ViewBaseTests` |
[13940077](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940077)
| ✅ |
| #34923 (SwipeView threshold) | `SwipeView,ViewBaseTests` |
[13940078](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940078)
| ✅ |
| #34907 (CollectionView ScrollTo) | `CollectionView` |
[13940079](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940079)
| ✅ |
| #34845 (RefreshView binding) | `RefreshView,ViewBaseTests` |
[13940080](https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=13940080)
| ✅ |

---------

Co-authored-by: Copilot <[email protected]>
github-actions Bot pushed a commit that referenced this pull request May 6, 2026
<!-- Please keep the note below for people who find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses an issue where the `SearchHandler.Query`
value was not displayed in the search bar on iOS and MacCatalyst at load
time. The fix ensures that the initial query value is shown as expected,
and includes new test coverage to prevent regressions.
### Description of Change
**Bug fix:**

* Ensured that the search bar's text is set to the `SearchHandler.Query`
value when attaching the search controller in
`ShellPageRendererTracker.cs`, so the initial query is visible on
iOS/MacCatalyst.

**Testing improvements:**

* Added an automated UI test (`Issue35005`) to verify that the
`SearchHandler.Query` value is visible in the search bar on page load
across all platforms.
* Introduced a new test case page (`Issue35005`) in the sample app to
facilitate manual and automated testing of this scenario.

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #35005 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="1125" height="2436"
alt="iOSQuerySetonInitialLoadBeforeFix"
src="https://github.com/user-attachments/assets/a37f23f4-c02b-4fe1-8c52-5b01a6c3aa11"
/> | <img width="1125" height="2436" alt="Simulator Screenshot - iPhone
Xs - 2026-04-17 at 16 05 47"
src="https://github.com/user-attachments/assets/b3db5f83-4ebd-4cd3-8b67-3d8945fb7873"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
github-actions Bot pushed a commit that referenced this pull request May 25, 2026
<!-- Please keep the note below for people who find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment whether this change resolves your
issue. Thank you!<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

This pull request addresses an issue where the `SearchHandler.Query`
value was not displayed in the search bar on iOS and MacCatalyst at load
time. The fix ensures that the initial query value is shown as expected,
and includes new test coverage to prevent regressions.
### Description of Change
**Bug fix:**

* Ensured that the search bar's text is set to the `SearchHandler.Query`
value when attaching the search controller in
`ShellPageRendererTracker.cs`, so the initial query is visible on
iOS/MacCatalyst.

**Testing improvements:**

* Added an automated UI test (`Issue35005`) to verify that the
`SearchHandler.Query` value is visible in the search bar on page load
across all platforms.
* Introduced a new test case page (`Issue35005`) in the sample app to
facilitate manual and automated testing of this scenario.

<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #35005 

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="1125" height="2436"
alt="iOSQuerySetonInitialLoadBeforeFix"
src="https://github.com/user-attachments/assets/a37f23f4-c02b-4fe1-8c52-5b01a6c3aa11"
/> | <img width="1125" height="2436" alt="Simulator Screenshot - iPhone
Xs - 2026-04-17 at 16 05 47"
src="https://github.com/user-attachments/assets/b3db5f83-4ebd-4cd3-8b67-3d8945fb7873"
/> |

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
@PureWeen PureWeen modified the milestones: .NET 10 SR7, .NET 10 SR8 Jun 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios platform/macos macOS / Mac Catalyst 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) shell-search-handler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS&Mac] Shell SearchHandler Query not shown in search bar on initial load

8 participants