Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
69 changes: 69 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue14708.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 14708, "Android SearchBar in landscape shows full-screen IME extract mode", PlatformAffected.Android)]
public class Issue14708 : ContentPage
{
Label _searchTextLabel;
SearchBar _primarySearchBar;

public Issue14708()
{
_searchTextLabel = new Label
{
Text = "Search text: (none)",
AutomationId = "SearchTextLabel",
FontSize = 13
};

_primarySearchBar = new SearchBar
{
Text = "Hello, landscape!",
Placeholder = "Tap here in landscape — keyboard should be inline",
AutomationId = "SearchBarControl"
};

var searchBar2 = new SearchBar
Comment thread
SubhikshaSf4851 marked this conversation as resolved.
{
Placeholder = "Second SearchBar",
AutomationId = "SearchBar2"
};


var searchBar3 = new SearchBar
{
Text = "Hello, landscape!",
Placeholder = "Third SearchBar",
AutomationId = "SearchBar3"
};


Content = new ScrollView
{
VerticalOptions = LayoutOptions.FillAndExpand,
Comment thread
SubhikshaSf4851 marked this conversation as resolved.
Outdated
Content = new VerticalStackLayout
{
Padding = new Thickness(16),
Spacing = 12,
Children =
{
new Label
{
Text = "Rotate to LANDSCAPE, then tap any SearchBar. " +
"The keyboard should appear inline at the bottom — " +
"NOT as a full-screen black overlay.",
HorizontalTextAlignment = TextAlignment.Center
},
_primarySearchBar,
_searchTextLabel,
new BoxView { HeightRequest = 1, Color = Colors.LightGray },
new Label { Text = "Additional SearchBars:", FontAttributes = FontAttributes.Italic, FontSize = 13 },
searchBar2,
searchBar3
}
}
};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#if ANDROID || iOS // Orientation changes and IME behavior are only relevant on mobile platforms
Comment thread
SubhikshaSf4851 marked this conversation as resolved.
Outdated
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue14708 : _IssuesUITest
{
public Issue14708(TestDevice device) : base(device) { }

public override string Issue => "Android SearchBar in landscape shows full-screen IME extract mode";

[TearDown]
public void TearDown()
{
App.SetOrientationPortrait();
}

[Test]
[Category(UITestCategories.SearchBar)]
public void SearchBarLandscapeShowsInlineKeyboardNotExtractMode()
{
// Rotate to landscape — this is the trigger condition for the bug
App.SetOrientationLandscape();

App.WaitForElement("SearchBarControl");

// Tap the primary SearchBar to open the keyboard
App.Tap("SearchBarControl");

// Wait a moment for keyboard to appear
Thread.Sleep(1000);
Comment thread
SubhikshaSf4851 marked this conversation as resolved.
Outdated

// In the unfixed state, Android enters IME extract mode in landscape:
// a full-screen black overlay replaces the inline keyboard and covers all
// page content. VerifyScreenshot() catches this because the visual output
// is dramatically different from the fixed (inline-keyboard) baseline.
Comment thread
SubhikshaSf4851 marked this conversation as resolved.
VerifyScreenshot(retryTimeout: TimeSpan.FromSeconds(2));
Comment thread
SubhikshaSf4851 marked this conversation as resolved.
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void OnEditorAction(object? sender, TextView.EditorActionEventArgs e)
{
var actionId = e.ActionId;
var evt = e.Event;
ImeAction currentInputImeFlag = PlatformView.EditText.ImeOptions;
ImeAction currentInputImeFlag = (ImeAction)((int)PlatformView.EditText.ImeOptions & (int)ImeAction.ImeMaskAction);
Comment thread
SubhikshaSf4851 marked this conversation as resolved.

// On API 34 the issue where actionId is ImeAction.ImeNull when using a hardware keyboard was fixed.
// Normalize it here so the rest of the logic is consistent across API levels.
Expand Down
2 changes: 2 additions & 0 deletions src/Core/src/Platform/Android/MauiSearchView.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Android.Content;
using Android.Views;
using Android.Views.InputMethods;
using Android.Widget;
using Java.IO;
using SearchView = AndroidX.AppCompat.Widget.SearchView;
Expand Down Expand Up @@ -30,6 +31,7 @@ void Initialize()
if (_queryEditor is not null)
{
_queryEditor.SaveEnabled = false;
_queryEditor.ImeOptions = (ImeAction)((int)_queryEditor.ImeOptions | (int)ImeFlags.NoFullscreen);
}

if (_queryEditor?.LayoutParameters is LinearLayout.LayoutParams layoutParams)
Expand Down
4 changes: 2 additions & 2 deletions src/Core/src/Platform/Android/SearchViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static void UpdateKeyboard(this SearchView searchView, ISearchBar searchB
public static void UpdateReturnType(this SearchView searchView, ISearchBar searchBar)
Comment thread
SubhikshaSf4851 marked this conversation as resolved.
{
searchView.SetInputType(searchBar);
searchView.ImeOptions = (int)searchBar.ReturnType.ToPlatform();
searchView.ImeOptions = (int)((ImeAction)searchBar.ReturnType.ToPlatform() | (ImeAction)(int)ImeFlags.NoFullscreen);
}

internal static void SetInputType(this SearchView searchView, ISearchBar searchBar, EditText? editText = null)
Expand Down Expand Up @@ -394,7 +394,7 @@ static bool TryGetDefaultStateColor(TextInputLayout textInputLayout, int attribu

internal static void UpdateReturnType(this EditText editText, ISearchBar searchBar)
{
editText.ImeOptions = searchBar.ReturnType.ToPlatform();
editText.ImeOptions = (ImeAction)((int)searchBar.ReturnType.ToPlatform() | (int)ImeFlags.NoFullscreen);

// Restart the input on the current focused EditText
InputMethodManager? imm = (InputMethodManager?)editText.Context?.GetSystemService(Context.InputMethodService);
Expand Down
Loading