Skip to content

[Android] The number of SearchHandler toolbar item increases abnormally - fix #29561

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 2 commits into
base: main
Choose a base branch
from

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented May 17, 2025

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!

Issues Fixed

Fixes #29499

Before After
Screen.Recording.2025-05-17.at.02.17.05.mov
Screen.Recording.2025-05-17.at.02.18.30.mov

@Copilot Copilot AI review requested due to automatic review settings May 17, 2025 00:21
@kubaflo kubaflo requested a review from a team as a code owner May 17, 2025 00:21
@kubaflo kubaflo requested review from jfversluis and jsuarezruiz May 17, 2025 00:21
@kubaflo kubaflo self-assigned this May 17, 2025
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 addresses an issue where the SearchHandler toolbar item would be added repeatedly on Android by assigning a fixed placeholder ID and separating tint updates from item updates.

  • Replaces the generic UpdateToolbarItems call in the TintColor setter with a new UpdateToolbarItemsTintColors method to avoid re-adding items.
  • Introduces a hard-coded placeholder menu item ID (100) when adding the search placeholder to prevent duplicates.
  • Adds two overloads of UpdateToolbarItemsTintColors (one private and one parameterless) to apply tint without touching item setup.
Comments suppressed due to low confidence (1)

src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellToolbarTracker.cs:634

  • Magic number 100 is used for the placeholder menu item ID in two places; consider extracting it into a named constant to avoid duplication and improve maintainability.
int _placeholderMenuItemId = 100;

if (menu.FindItem(_placeholderMenuItemId) is IMenuItem item)
{
using (var icon = item.Icon)
icon.SetColorFilter(TintColor.ToPlatform(Colors.White), FilterMode.SrcAtop);
Copy link
Preview

Copilot AI May 17, 2025

Choose a reason for hiding this comment

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

The color filter is hard-coded to white (using Colors.White) instead of the actual TintColor; you should apply the intended TintColor (e.g., TintColor.ToPlatform()) to respect the configured tint.

Suggested change
icon.SetColorFilter(TintColor.ToPlatform(Colors.White), FilterMode.SrcAtop);
icon.SetColorFilter((TintColor?.ToPlatform() ?? Colors.White.ToPlatform()), FilterMode.SrcAtop);

Copilot uses AI. Check for mistakes.

Copy link
Contributor

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

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

App.Click("GoBackButton");
App.WaitForElement("GotoIssue29499Subpage");
((AppiumApp)App).Driver.FindElement(OpenQA.Selenium.By.XPath("//*[@content-desc=\"More options\"]")).Click();
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

Pending snapshots, running a Build.

Copy link
Contributor

Choose a reason for hiding this comment

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

image
Could you commit the image?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] The number of SearchHandler toolbar item increases abnormally
2 participants