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 @@ -20,7 +20,7 @@ void OnWindowDispatchedTouch(object? sender, MotionEvent? e)

foreach (var page in _contentPages)
{
if (page.HasNavigatedTo &&
if ((page.HasNavigatedTo || page.Parent is Window) &&
page.HideSoftInputOnTapped &&
page.Handler is IPlatformViewHandler pvh &&
pvh.MauiContext?.Context is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ partial class HideSoftInputOnTappedChangedManager

internal void UpdatePage(ContentPage page)
{
if (page.HideSoftInputOnTapped && page.HasNavigatedTo)
if (page.HideSoftInputOnTapped && (page.HasNavigatedTo || page.Parent is Window))
{
if (!_contentPages.Contains(page))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bool FeatureEnabled
{
foreach (var page in _contentPages)
{
if (page.HideSoftInputOnTapped && page.HasNavigatedTo)
if (page.HideSoftInputOnTapped && (page.HasNavigatedTo || page.Parent is Window))
return true;
}
return false;
Expand Down
40 changes: 40 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue26792.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 26792, "HideSoftInputOnTapped Not Working", PlatformAffected.Android)]
public class Issue26792 : ContentPage
{

VerticalStackLayout stackLayout;
Button _button;

Entry _entry;
public Issue26792()
{
this.HideSoftInputOnTapped = true;
stackLayout = new VerticalStackLayout
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
AutomationId = "Issue26792StackLayout",
};
_button = new Button
{
Text = "Click Me",
AutomationId = "Issue26792Button",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
};
_entry = new Entry
{
Placeholder = "Enter text",
AutomationId = "Issue26792Entry",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
};

stackLayout.Children.Add(_button);
stackLayout.Children.Add(_entry);
Content = stackLayout;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS //As SoftKeyboard is not supported
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue26792 : _IssuesUITest
{
public Issue26792(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "HideSoftInputOnTapped Not Working";

[Test]
[Category(UITestCategories.Page)]
public void SoftInputShouldHiddenOnTap()
{
App.WaitForElement("Issue26792Entry");
App.Tap("Issue26792Entry");
App.WaitForElement("Issue26792Button");
App.Tap("Issue26792Button");
App.WaitForElement("Issue26792Entry");
Assert.That(App.IsKeyboardShown(), Is.False);

}
}
#endif