dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

[Android] Line breaks not occurring when pressing Enter in Entry configured as multiline, even with ImeOptions set to None. #25952

Open KrithikaIrulappan18 opened 2 days ago

KrithikaIrulappan18 commented 2 days ago

Description

In .NET MAUI, pressing the "Enter" key in the Entry field does not produce a line break by default. Although platform-specific workarounds have been implemented to enable multiline behavior, this functionality fails on certain Samsung Android devices, including the Samsung F14, Samsung Galaxy S8+ Tablet, Samsung Galaxy Active Tab 3, and Samsung Galaxy Fold 6. It is suspected that, on these devices, the "Enter" key triggers the "Done" or "Send" action instead of inserting a line break. Even after setting ImeOptions to None, the expected line break functionality does not work when the "Enter" key is pressed.

Steps to Reproduce

1.Create a .NET MAUI application with an Entry field intended to support multiline input.

var entry = new Entry
           {
               Placeholder = "Enter your text here...",
               HeightRequest = 150, // Height to accommodate multiple lines
               HorizontalOptions = LayoutOptions.FillAndExpand,
               VerticalOptions = LayoutOptions.StartAndExpand
           };

2.Apply platform-specific configurations to enable multiline behavior, including setting ImeOptions to None for Android.

entry.HandlerChanged += (sender, args) =>
           {
               if (entry.Handler != null)
               {
#if ANDROID
                   if (entry.Handler.PlatformView is EditText editText)
                   {
                        editText.SetSingleLine(false); // Allow multiline behavior
                        editText.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextFlagMultiLine;
                        editText.ImeOptions = Android.Views.InputMethods.ImeAction.None;
                        editText.SetHorizontallyScrolling(false); // Wrap text within bounds
                        editText.SetPadding(10, 10, 10, 10); // Add some padding for better appearance
                   }
#endif
               }
           };
           // Add the entry to the layout
           Content = new StackLayout
           {
               Padding = new Thickness(20),
               Children = { entry }
           };

3.Deploy the application to the following Samsung Android devices:

4.Focus on the Entry field and press the "Enter" key on the keyboard. 5.Observe whether a line break occurs in the Entry field.

Link to public reproduction project repository

No response

Version with bug

.NET 8.0

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14

Did you find any workaround?

No response

Relevant log output

dotnet-policy-service[bot] commented 1 day ago

Hi @KrithikaIrulappan18. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.