[Android] The number of SearchHandler toolbar item increases abnormally - fix#29561
Merged
PureWeen merged 3 commits intodotnet:inflight/currentfrom May 22, 2025
Merged
[Android] The number of SearchHandler toolbar item increases abnormally - fix#29561PureWeen merged 3 commits intodotnet:inflight/currentfrom
PureWeen merged 3 commits intodotnet:inflight/currentfrom
Conversation
Contributor
There was a problem hiding this comment.
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
UpdateToolbarItemscall in theTintColorsetter with a newUpdateToolbarItemsTintColorsmethod 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); |
There was a problem hiding this comment.
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); |
Contributor
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
jsuarezruiz
suggested changes
May 19, 2025
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
StephaneDelcroix
approved these changes
May 22, 2025
github-actions bot
pushed a commit
that referenced
this pull request
May 22, 2025
…ly - fix (#29561) * [Android] The number of SearchHandler toolbar item increases abnormally - fix * Added a UI test * Create NumberOfToolbarItemsShouldNotIncrease.png
github-actions bot
pushed a commit
that referenced
this pull request
May 30, 2025
…ly - fix (#29561) * [Android] The number of SearchHandler toolbar item increases abnormally - fix * Added a UI test * Create NumberOfToolbarItemsShouldNotIncrease.png
github-actions bot
pushed a commit
that referenced
this pull request
May 30, 2025
…ly - fix (#29561) * [Android] The number of SearchHandler toolbar item increases abnormally - fix * Added a UI test * Create NumberOfToolbarItemsShouldNotIncrease.png
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Fixes #29680
Screen.Recording.2025-05-17.at.02.17.05.mov
Screen.Recording.2025-05-17.at.02.18.30.mov