[iOS] Fixed Shell navigation on search handler suggestion selection#33406
[iOS] Fixed Shell navigation on search handler suggestion selection#33406PureWeen merged 9 commits intodotnet:inflight/currentfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an iOS-specific issue where Shell navigation fails when selecting items from SearchHandler suggestions. The root cause is that dismissing the UISearchController before calling ItemSelected triggers a UIKit transition that deactivates the Shell navigation context, preventing navigation from completing.
Key Changes:
- Reordered operations in
OnSearchItemSelectedto callItemSelectedbefore setting_searchController.Active = false - Added comprehensive UI test coverage for SearchHandler navigation behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs |
Swapped the order of operations in OnSearchItemSelected to fix the navigation timing issue |
src/Controls/tests/TestCases.HostApp/Issues/Issue33356.cs |
Added HostApp test page with Shell, SearchHandler, and navigation structure to reproduce the issue |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33356.cs |
Added UI test that verifies navigation works from both SearchHandler results and CollectionView |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33356.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33356.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33356.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33356.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33356.cs
Outdated
Show resolved
Hide resolved
PR Review: #33406 - [iOS] Fixed Shell navigation on search handler suggestion selectionDate: 2026-01-07 | Issue: #33356 | PR: #33406 ⏳ Status: COMPLETE
📋 Issue SummaryIssue #33356: [iOS] Clicking on search suggestions fails to navigate to detail page correctly Root Cause: Navigation fails because Steps to Reproduce:
Platforms Affected:
Regression: Yes - This is a regression from version 9.0.90 according to issue validation comment. Issue Labels: 📁 Files Changed
Fix Classification: iOS-specific Shell navigation bug (platform handler) Test Type: UI Tests (Shell category) 💬 PR Discussion SummaryKey Comments:
Reviewer Feedback:
Disagreements to Investigate:
Author Uncertainty:
🧪 TestsStatus: ✅ COMPLETE
Test Files:
Test Description:
🚦 Gate - Test VerificationStatus: ✅ PASSED
Result: Verification Details:
🔧 Fix CandidatesStatus: ✅ COMPLETE
Exhausted: No (PR fix is correct and sufficient) 🔍 Root Cause AnalysisProblem: When a user selects a search suggestion in Shell's SearchHandler on iOS, the navigation fails silently. Root Cause: The original code dismissed the UISearchController ( Why This Matters:
Fix: Simply swap the order - call Code Change: void OnSearchItemSelected(object? sender, object e)
{
if (_searchController is null)
return;
- _searchController.Active = false;
(SearchHandler as ISearchHandlerController)?.ItemSelected(e);
+ _searchController.Active = false;
}Why This Fix Works:
✅ Fix ValidationVerification Results:
Alternative Approaches Considered:
PR Fix is Optimal: Simple, direct, addresses root cause without side effects. 📊 Quality Assessment
Strengths:
No Issues Found ✅ Final Recommendation: APPROVEVerdict: This PR correctly fixes the iOS Shell navigation bug with a minimal, well-tested solution. Summary:
Recommendation: ✅ APPROVE - Ready to merge Next Step: Verify tests compile and reproduce the issue (Phase 2: Tests) |
|
/rebase |
Tracks review progress for iOS Shell SearchHandler navigation fix. Pre-flight context gathered from issue dotnet#33356 and related PRs.
PureWeen
left a comment
There was a problem hiding this comment.
UI Test Code Style Feedback
The fix looks correct, but the UI test has inline #if directives that should be refactored for code cleanliness.
Issue
File: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33356.cs
The test uses inline #if ANDROID ... #else ... blocks (lines 9-13 and 28-34). Per our UI test guidelines, platform-specific behavior should be hidden behind extension methods to keep test code readable.
Suggested Fix
Move the platform-specific tapping logic to an extension method:
// In UtilExtensions.cs (or a new extension class)
public static void TapFirstSearchResult(this IApp app, UITestContextBase context, IUIElement searchHandler)
{
if (context.Device == TestDevice.Android)
{
// Android does not support selecting elements in SearchHandler results
var y = searchHandler.GetRect().Y + searchHandler.GetRect().Height;
app.TapCoordinates(searchHandler.GetRect().X + 10, y + 10);
}
else
{
var searchResults = app.FindElements("SearchResultName");
searchResults.First().Tap();
}
}Then the test becomes cleaner:
var searchHandler = App.GetShellSearchHandler();
searchHandler.Tap();
searchHandler.SendKeys("A");
App.TapFirstSearchResult(this, searchHandler); // Clean!Similarly, the BackButtonIdentifier constant could be handled via an extension method or the existing TapBackArrow could be updated to handle the platform difference internally.
Note: This is a code style request only. The actual fix (swapping ItemSelected() before Active = false) looks correct.
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Improves agent/skill documentation for automated PR reviews and UI test
authoring.
### Agent Workflow Documentation (Updated)
**`.github/agents/pr.md`**
- Clarify state file commit rule: state file should always be included
when committing changes
**`.github/instructions/uitests.instructions.md`**
- Add rule prohibiting inline `#if` platform directives in test methods
- Require platform-specific logic to be in extension methods for better
readability:
```csharp
// ❌ Hard to read
[Test]
public void MyTest()
{
#if ANDROID
App.TapCoordinates(100, 200);
#else
App.Tap("MyElement");
#endif
}
// ✅ Clean and readable
[Test]
public void MyTest()
{
App.TapElementCrossPlatform("MyElement");
}
```
**`.github/skills/try-fix/SKILL.md`**
- Add "Model" column to Fix Candidates table format to track which AI
model generated each fix attempt
### Summary
These changes provide clearer guidelines for automated PR reviews and UI
test authoring.
<!-- START COPILOT CODING AGENT SUFFIX -->
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
> Can you create a PR with the changes from the ".github" folder on
#33406 and
#31487
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/dotnet/maui/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
- Add 'No Inline #if Directives in Test Methods' section - Clarify rule is about code cleanliness, not platform scope - Provide bad/good examples showing extension method pattern - Update 'Before Committing' checklist with new requirement - Simplify Platform Coverage section for clarity
Tracks review progress for iOS Shell SearchHandler navigation fix. Pre-flight context gathered from issue dotnet#33356 and related PRs.
- Add COMMIT RULE callout explaining why state file must be committed - Add 'Commit and push the state file' step to each phase completion - Ensures session state persists for future agent invocations
Remove per-phase 'commit and push' steps - just note that state file should always be included when committing other changes.
54d1af2 to
02ae13c
Compare
|
@PureWeen As suggested I have added the extension method |
…33406) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root Cause : Navigation fails because `UISearchController` was dismissed before `ItemSelected` was called, triggering a UIKit transition that deactivates the Shell navigation context and prevents the navigation from completing ### Description of Change : Changed the order in `OnSearchItemSelected` in `ShellPageRendererTracker.cs` to call `ItemSelected` before deactivating the search controller for correct event handling. <!-- 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 #33356 ### Tested the behavior in the following platforms - [x] Windows - [x] Android - [x] iOS - [x] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/0e63dd86-1965-404a-8d07-6d3afd952498"> | <video src="https://github.com/user-attachments/assets/af867272-434f-411e-9a6f-a68a87cfc3a7"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
…33406) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root Cause : Navigation fails because `UISearchController` was dismissed before `ItemSelected` was called, triggering a UIKit transition that deactivates the Shell navigation context and prevents the navigation from completing ### Description of Change : Changed the order in `OnSearchItemSelected` in `ShellPageRendererTracker.cs` to call `ItemSelected` before deactivating the search controller for correct event handling. <!-- 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 #33356 ### Tested the behavior in the following platforms - [x] Windows - [x] Android - [x] iOS - [x] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/0e63dd86-1965-404a-8d07-6d3afd952498"> | <video src="https://github.com/user-attachments/assets/af867272-434f-411e-9a6f-a68a87cfc3a7"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
…33406) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root Cause : Navigation fails because `UISearchController` was dismissed before `ItemSelected` was called, triggering a UIKit transition that deactivates the Shell navigation context and prevents the navigation from completing ### Description of Change : Changed the order in `OnSearchItemSelected` in `ShellPageRendererTracker.cs` to call `ItemSelected` before deactivating the search controller for correct event handling. <!-- 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 #33356 ### Tested the behavior in the following platforms - [x] Windows - [x] Android - [x] iOS - [x] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/0e63dd86-1965-404a-8d07-6d3afd952498"> | <video src="https://github.com/user-attachments/assets/af867272-434f-411e-9a6f-a68a87cfc3a7"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
…33406) <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Root Cause : Navigation fails because `UISearchController` was dismissed before `ItemSelected` was called, triggering a UIKit transition that deactivates the Shell navigation context and prevents the navigation from completing ### Description of Change : Changed the order in `OnSearchItemSelected` in `ShellPageRendererTracker.cs` to call `ItemSelected` before deactivating the search controller for correct event handling. <!-- 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 #33356 ### Tested the behavior in the following platforms - [x] Windows - [x] Android - [x] iOS - [x] Mac | Before Issue Fix | After Issue Fix | |----------|----------| | <video src="https://github.com/user-attachments/assets/0e63dd86-1965-404a-8d07-6d3afd952498"> | <video src="https://github.com/user-attachments/assets/af867272-434f-411e-9a6f-a68a87cfc3a7"> | <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. --> --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
## What's Coming .NET MAUI inflight/candidate introduces significant improvements across all platforms with focus on quality, performance, and developer experience. This release includes 16 commits with various improvements, bug fixes, and enhancements. ## Checkbox - [Android] Implement material3 support for CheckBox by @HarishwaranVijayakumar in #33339 <details> <summary>🔧 Fixes</summary> - [Implement Material3 Support for CheckBox](#33338) </details> ## CollectionView - [Android] Fixed EmptyView doesn’t display when CollectionView is placed inside a VerticalStackLayout by @NanthiniMahalingam in #33134 <details> <summary>🔧 Fixes</summary> - [CollectionView does not show an EmptyView template with an empty collection](#32932) </details> ## Essentials - [Windows]Fix NullReferenceException in OpenReadAsync for FileResult created with full path by @devanathan-vaithiyanathan in #28238 <details> <summary>🔧 Fixes</summary> - [[Windows] FileResult(string fullPath) not initialized properly](#26858) </details> ## Image - Fix Glide IllegalArgumentException in MauiCustomTarget.clear() for destroyed activities by @jfversluis via @Copilot in #29780 <details> <summary>🔧 Fixes</summary> - [java.lang.IllegalArgumentException: You cannot start a load for a destroyed activity - glide](#29699) </details> ## Label - [Android] Fix for Label WordWrap width issue causing HorizontalOptions misalignment by @praveenkumarkarunanithi in #33281 <details> <summary>🔧 Fixes</summary> - [[Android] Unexpected Line Breaks in Android, Label with WordWrap Mode Due to Trailing Space.](#31782) - [Label not sized correctly on Android](#27614) </details> - Fix to Improve Flyout Accessibility by Adjusting UITableViewController Labels by @SuthiYuvaraj in #31619 <details> <summary>🔧 Fixes</summary> - [Navigation section present under hamburger are programmatically define as table :A11y_.NET maui_User can get all the insights of Dashboard_Devtools](#30894) </details> ## Mediapicker - [Regression][iOS] Fix MediaPicker PickPhotosAsync getting file name in contentType property by @devanathan-vaithiyanathan in #33390 <details> <summary>🔧 Fixes</summary> - [[iOS] MediaPicker PickPhotosAsync getting file name in contentType property](#33348) </details> ## Navigation - Fix handler not disconnected when removing non visible pages using RemovePage() by @Vignesh-SF3580 in #32289 <details> <summary>🔧 Fixes</summary> - [NavigationPage.Navigation.RemovePage() fails to disconnect handlers when removing pages, unlike ContentPage.Navigation.RemovePage()](#32239) </details> ## Picker - [Android] Fix Picker IsOpen not reset when picker is dismissed by @devanathan-vaithiyanathan in #33332 <details> <summary>🔧 Fixes</summary> - [[Android] Picker IsOpen not reset when picker is dismissed](#33331) </details> ## Shell - [iOS & Catalyst ] Fixed IsEnabled property should work on Tabs by @SubhikshaSf4851 in #33369 <details> <summary>🔧 Fixes</summary> - [[Catalyst] TabBarBackgroundColor, TabBarUnselectedColor, and IsEnabled Not Working as Expected in Shell](#33158) </details> - [iOS,Windows] Fix navigation bar colors not resetting when switching ShellContent by @Vignesh-SF3580 in #33228 <details> <summary>🔧 Fixes</summary> - [[iOS, Windows] Shell Navigation bar colors are not updated correctly when switching ShellContent](#33227) </details> - [iOS] Fixed Shell navigation on search handler suggestion selection by @SubhikshaSf4851 in #33406 <details> <summary>🔧 Fixes</summary> - [[iOS] Clicking on search suggestions fails to navigate to detail page correctly](#33356) </details> ## Templates - Fix VoiceOver doesnot announces the State of the ComboBox by @SuthiYuvaraj in #32286 ## Xaml - [XSG][BindingSourceGen] Add support for CommunityToolkit.Mvvm ObservablePropertyAttribute by @simonrozsival via @Copilot in #33028 <details> <summary>🔧 Fixes</summary> - [[XSG] Add heuristic to support bindable properties generated by other source generators](#32597) </details> <details> <summary>📦 Other (2)</summary> - [XSG] Improve diagnostic reporting during binding compilation by @simonrozsival via @Copilot in #32905 - [Testing] Fixed Test case failure in PR 33574 - [01/19/2026] Candidate - 1 by @TamilarasanSF4853 in #33602 </details> **Full Changelog**: main...inflight/candidate
…ions from analysis New agent: .github/agents/scrape-and-improve.md Applied findings: Common Fix Patterns section in copilot-instructions.md - NavigationPage handler disconnection (from PR #32289 - 6 attempts) - CollectionView EmptyView Android (from PR #33134 - 8 attempts) - Shell navigation iOS tests (from PR #33380 - 4 attempts) - Device test isolation (from PR #33406 - 3 attempts) Scrape results: 5 sessions, 21 fix attempts, 47.6% success rate, 7 recommendations Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Root Cause :
Navigation fails because
UISearchControllerwas dismissed beforeItemSelectedwas called, triggering a UIKit transition that deactivates the Shell navigation context and prevents the navigation from completingDescription of Change :
Changed the order in
OnSearchItemSelectedinShellPageRendererTracker.csto callItemSelectedbefore deactivating the search controller for correct event handling.Issues Fixed
Fixes #33356
Tested the behavior in the following platforms
Screen.Recording.2026-01-07.at.11.49.23.mov
Screen.Recording.2026-01-07.at.11.48.07.mov