Skip to content

[Android] Fix for SearchHandler retaining previous page SearchView data in pages within Shell sections #29545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

BagavathiPerumal
Copy link
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 if this change resolves your issue. Thank you!

Root cause

The issue occurs because SearchHandler references don't update properly during ShellSection page navigation. While SearchView instances are intentionally preserved for performance, the system failed to synchronize the SearchHandler reference when transitioning between pages. This caused search functionality to continue using the previous page's configuration instead of adopting the current page's settings, resulting in inconsistent search behavior and incorrect UI elements.

Description of Issue Fix

The fix involves adding a synchronization check that detects when the SearchView's SearchHandler doesn't match the current page's SearchHandler. When a mismatch is detected, the code updates the SearchView with the correct SearchHandler and refreshes the view. This ensures search functionality always reflects the current page context during navigation, preventing inconsistent behavior and UI elements.

Tested the behavior in the following platforms.

  • Windows
  • Mac
  • iOS
  • Android

Issues Fixed

Fixes #8716

Output

Before Issue Fix After Issue Fix
SearchHandler-BeforeFix.mov
SearchHandler-AfterFix.mov

Copy link
Contributor

Hey there @@BagavathiPerumal! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels May 16, 2025
@BagavathiPerumal BagavathiPerumal marked this pull request as ready for review May 16, 2025 11:46
@Copilot Copilot AI review requested due to automatic review settings May 16, 2025 11:46
@BagavathiPerumal BagavathiPerumal requested a review from a team as a code owner May 16, 2025 11:46
Copy link
Contributor

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

This PR fixes an Android issue where the SearchHandler retained outdated SearchView data when navigating between Shell pages.

  • Updates the SearchHandler reference during page navigation in Shell to ensure it reflects the current page's configuration.
  • Adds corresponding tests in the shared and host app test projects.

Reviewed Changes

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

File Description
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue8716.cs Adds a UI test verifying that the SearchHandler updates correctly during page navigation.
src/Controls/tests/TestCases.HostApp/Issues/Issue8716.cs Implements Shell pages for Cats and Dogs with distinct SearchHandler settings.
src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellToolbarTracker.cs Introduces logic to update the SearchView’s SearchHandler if it mismatches the current page’s SearchHandler.
Comments suppressed due to low confidence (1)

src/Controls/tests/TestCases.HostApp/Issues/Issue8716.cs:92

  • [nitpick] Consider using a more descriptive AutomationId to differentiate this button from similar elements on other pages (e.g. using 'CatsPageButton' instead of 'MainPageButton').
var button = new Button { Text = "Button", AutomationId = "MainPageButton" }

@@ -646,6 +646,11 @@ protected virtual void UpdateToolbarItems(AToolbar toolbar, Page page)
_searchView.View.LayoutParameters = new LP(LP.MatchParent, LP.MatchParent);
_searchView.SearchConfirmed += OnSearchConfirmed;
}
else if (_searchView.SearchHandler != SearchHandler)
Copy link
Preview

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

Consider adding explicit null checks when comparing _searchView.SearchHandler with SearchHandler to ensure robust handling in cases where one of them might be null.

Suggested change
else if (_searchView.SearchHandler != SearchHandler)
else if (_searchView.SearchHandler != null && SearchHandler != null && _searchView.SearchHandler != SearchHandler)

Copilot uses AI. Check for mistakes.

@jsuarezruiz jsuarezruiz added platform/android area-controls-shell Shell Navigation, Routes, Tabs, Flyout labels May 16, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Shell][Android] The truth is out there...but not on top tab search handlers
3 participants