Skip to content
Draft
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 @@ -732,7 +732,7 @@ void AttachSearchController()
{
SearchHandler.SetValue(SearchHandler.QueryProperty, sc.SearchBar.Text);
});

searchBar.OnEditingStopped += OnEditingCompleted;
searchBar.BookmarkButtonClicked += BookmarkButtonClicked;

searchBar.Placeholder = SearchHandler.Placeholder;
Expand Down Expand Up @@ -767,6 +767,11 @@ void AttachSearchController()
UpdateAutomationId();
}

void OnEditingCompleted(object sender, EventArgs e)
{
_searchController.Active = false;
}

void BookmarkButtonClicked(object sender, EventArgs e)
{
((ISearchHandlerController)SearchHandler).ClearPlaceholderClicked();
Expand All @@ -785,6 +790,10 @@ void DettachSearchController()
NavigationItem.TitleView = null;
}

if (_searchController?.SearchBar is not null)
{
_searchController.SearchBar.OnEditingStopped -= OnEditingCompleted;
}
_searchController.SetSearchResultsUpdater(null);
_searchController.Dispose();
_searchController = null;
Expand All @@ -798,6 +807,7 @@ void OnSearchItemSelected(object sender, object e)

void SearchButtonClicked(object sender, EventArgs e)
{
_searchController.Active = false;
((ISearchHandlerController)SearchHandler).QueryConfirmed();
}

Expand Down Expand Up @@ -919,6 +929,11 @@ protected virtual void Dispose(bool disposing)
tvc.Disconnect();
}

if (_searchController?.SearchBar is not null)
{
_searchController.SearchBar.OnEditingStopped -= OnEditingCompleted;
}

_context = null;
SearchHandler = null;
Page = null;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue14448.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 14448, "maui title bar disappears and does not re-appear on iOS when using shell.searchhandler", PlatformAffected.iOS)]
public class Issue14448 : Shell
{
public Issue14448()
{
// Create a simple ShellContent with a content page
var shellContent = new ShellContent
{
Title = "Home",
Content = new Issue14448Page()
};
FlyoutBehavior = FlyoutBehavior.Flyout;

// Add to root of the Shell
Items.Add(shellContent);
}
}

public class Issue14448Page : ContentPage
{
public Issue14448Page()
{
Title = "Home";

// Create search handler
var searchHandler = new SearchHandler
{
Placeholder = "SearchHandler",
ShowsResults = false,
BackgroundColor = Colors.White,
TextColor = Colors.Black,
AutomationId = "SearchHandler"
};

// Set search handler on page
Shell.SetSearchHandler(this, searchHandler);

// Create content
Content = new VerticalStackLayout
{
Children =
{
new Label
{
Text = "Welcome to .NET MAUI!",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
}
}
};
}
}
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,30 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue14448 : _IssuesUITest
{
public Issue14448(TestDevice testDevice) : base(testDevice)
{
}
public override string Issue => "maui title bar disappears and does not re-appear on iOS when using shell.searchhandler";

[Test]
[Category(UITestCategories.Shell)]
public void ShellTitleShouldNotDisappear()
{
// Try to locate the search field by placeholder text
App.WaitForElement("SearchHandler");

// Tap on the search field to focus it
App.Tap("SearchHandler");

// Enter text into the search field
App.EnterText("SearchHandler", "Item 1");
// Dismiss keyboard by tapping return/search on iOS
App.PressEnter();
VerifyScreenshot();
}
}
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