Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace Microsoft.Maui.Controls.Platform.Compatibility
{
public class ShellToolbarTracker : Java.Lang.Object, AView.IOnClickListener, IShellToolbarTracker, IFlyoutBehaviorObserver
{
const int _placeholderMenuItemId = 100;
#region IFlyoutBehaviorObserver

void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
Expand Down Expand Up @@ -632,7 +633,6 @@ protected virtual void UpdateTitleView(Context context, AToolbar toolbar, View t
private void UpdateToolbarItemsTintColors(AToolbar toolbar)
{
var menu = toolbar.Menu;
int _placeholderMenuItemId = 100;
if (menu.FindItem(_placeholderMenuItemId) is IMenuItem item)
{
using (var icon = item.Icon)
Expand All @@ -643,7 +643,6 @@ private void UpdateToolbarItemsTintColors(AToolbar toolbar)
protected virtual void UpdateToolbarItems(AToolbar toolbar, Page page)
{
var menu = toolbar.Menu;
int _placeholderMenuItemId = 100;
SearchHandler = Shell.GetSearchHandler(page);
if (SearchHandler != null && SearchHandler.SearchBoxVisibility != SearchBoxVisibility.Hidden)
{
Expand All @@ -662,6 +661,8 @@ protected virtual void UpdateToolbarItems(AToolbar toolbar, Page page)

if (SearchHandler.SearchBoxVisibility == SearchBoxVisibility.Collapsible)
{
menu.RemoveItem(_placeholderMenuItemId);

var placeholder = new Java.Lang.String(SearchHandler.Placeholder);
var item = menu.Add(0, _placeholderMenuItemId, 0, placeholder);
placeholder.Dispose();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue21119.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 21119, "Search Handler visual and functional bug in subtabs", PlatformAffected.Android)]
public class Issue21119 : Shell
{
public Issue21119()
{
FlyoutBehavior = FlyoutBehavior.Flyout;

var flyoutItem = new FlyoutItem
{
Route = "animals",
FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems
};

var domesticTab = new Tab
{
Title = "Domestic",
Route = "domestic"
};

domesticTab.Items.Add(new ShellContent
{
Title = "CatsPage",
Route = "cats",
ContentTemplate = new DataTemplate(typeof(_21119CatsPage))
});

domesticTab.Items.Add(new ShellContent
{
Title = "DogsPage",
Route = "dogs",
ContentTemplate = new DataTemplate(typeof(_21119DogsPage))
});

flyoutItem.Items.Add(domesticTab);

Items.Add(flyoutItem);
}

public class _21119CatsPage : ContentPage
{
public _21119CatsPage()
{
Title = "CatsPage";

var searchHandler = new _21119AnimalSearchHandler
{
Placeholder = "Search cats...",
ShowsResults = true
};

var catPageButton = new Button
{
Text = "CatPageButton",
AutomationId = "CatPageButton"
};

Content = new StackLayout
{
Children =
{
catPageButton
}
};

Shell.SetSearchHandler(this, searchHandler);
}
}

public class _21119DogsPage : ContentPage
{
public _21119DogsPage()
{
Title = "DogsPage";

var searchHandler = new _21119AnimalSearchHandler
{
Placeholder = "Search dogs...",
ShowsResults = true
};

Shell.SetSearchHandler(this, searchHandler);

var dogPageButton = new Button
{
Text = "DogPageButton",
AutomationId = "DogsPageButton"
};

Content = new StackLayout
{
Children =
{
dogPageButton
}
};
}
}

public class _21119AnimalSearchHandler : SearchHandler
{
public _21119AnimalSearchHandler()
{
SearchBoxVisibility = SearchBoxVisibility.Collapsible;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue21119 : _IssuesUITest
{
public Issue21119(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Search Handler visual and functional bug in subtabs";

[Test]
[Category(UITestCategories.Shell)]
public void UpdateSearchHandlerMenuItemForTabNavigation()
{
#if WINDOWS
App.Tap("navViewItem");
App.WaitForElement("DogsPage");
App.Tap("DogsPage");
App.Tap("navViewItem");
App.WaitForElement("CatsPage");
App.Tap("CatsPage");
#else
App.WaitForElement("CatPageButton");
App.TapTab("DogsPage");
App.WaitForElement("DogPageButton");
App.TapTab("CatsPage");
#endif
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 Author

Choose a reason for hiding this comment

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

@jsuarezruiz, I have successfully added snapshots for Mac and Windows.

}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading