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.28k 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. #26353

Open KrithikaIrulappan18 opened 12 hours ago

KrithikaIrulappan18 commented 12 hours 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.

Please find sample for reproducing the issue EntryFormField.zip

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

No response

Did you find any workaround?

No response

Relevant log output

similar-issues-ai[bot] commented 12 hours ago

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

KrithikaIrulappan18 commented 12 hours ago

The previous reported issue was closed (https://github.com/dotnet/maui/issues/25952)) ,Eventhough I had attached sample in comments ,It doesn't reopened. Now I have attached the sample[ EntryFormField] in repro steps.

kevinxufei commented 10 hours ago

I can repro this issue at Galaxy S22 SM-S9010 on the latest 17.13 Preview 1(8.0.93 & 8.0.100).