Skip to content

Conversation

SubhikshaSf4851
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!

RootCause:

UpdateTitleIcon always added a new ToolbarTitleIconImageView without checking for an existing one, causing duplicate icons when TitleIconImageSource was set multiple times.

Description of Change

Modified UpdateTitleIcon method to check for an existing ToolbarTitleIconImageView and only add a new one if necessary, ensuring that duplicate icons are not created when the title icon is set multiple times.

Issues Fixed

Fixes #31445

Tested the behavior in the following platforms

  • Windows
  • Android
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
BeforeFix31445.mov
AfterFix31445.mov

Copy link
Contributor

Hey there @@SubhikshaSf4851! 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 Sep 5, 2025
@SubhikshaSf4851 SubhikshaSf4851 marked this pull request as ready for review September 5, 2025 07:31
@Copilot Copilot AI review requested due to automatic review settings September 5, 2025 07:31
@SubhikshaSf4851 SubhikshaSf4851 requested a review from a team as a code owner September 5, 2025 07:31
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 pull request fixes a bug where duplicate title icons would appear in Android navigation bars when the TitleIconImageSource property was set multiple times. The issue was caused by the UpdateTitleIcon method always creating a new ToolbarTitleIconImageView without checking for existing ones.

Key changes:

  • Modified the UpdateTitleIcon method to check for existing ToolbarTitleIconImageView before creating new ones
  • Added proper reuse logic to prevent duplicate icons
  • Included test cases to verify the fix

Reviewed Changes

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

File Description
src/Controls/src/Core/Platform/Android/Extensions/ToolbarExtensions.cs Updated UpdateTitleIcon method to check for existing icon views and reuse them instead of always creating new ones
src/Controls/tests/TestCases.HostApp/Issues/Issue31445.cs Added test page that reproduces the duplicate icon issue by setting TitleIconImageSource multiple times
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31445.cs Added UI test that verifies the fix by checking that only one title icon appears after button interaction

VerticalOptions = LayoutOptions.Start,
AutomationId = "Issue31445Button"
};
button.Clicked += (s, e) => { NavigationPage.SetTitleIconImageSource(this, "dotnet_bot.png"); };
Copy link
Preview

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

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

The test only sets the same image source again. To better validate the fix, consider testing with different image sources or setting the same source multiple times in rapid succession to ensure the duplicate prevention works in various scenarios.

Copilot uses AI. Check for mistakes.

@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-titleview TitleView 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.

[Android] Duplicate Title Icon Appears When Setting NavigationPage.TitleIconImageSource Multiple Times
2 participants