Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KrithikaIrulappan18 opened this issue Nov 19, 2024 · 1 comment
Labels
area-controls-entry Entry platform/android 🤖 s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working

Comments

@KrithikaIrulappan18
Copy link

KrithikaIrulappan18 commented Nov 19, 2024

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:

  • Samsung F14
  • Samsung Galaxy S8+ Tablet
  • Samsung Galaxy Active Tab 3
  • Samsung Galaxy Fold 6

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

@KrithikaIrulappan18 KrithikaIrulappan18 added the t/bug Something isn't working label Nov 19, 2024
@KrithikaIrulappan18 KrithikaIrulappan18 changed the title [Android]Line breaks not occurring when pressing Enter in Entry which behaves as multi-line. [Android] Line breaks not occurring when pressing Enter in Entry configured as multiline, even with ImeOptions set to None. Nov 19, 2024
@PureWeen PureWeen added the s/needs-repro Attach a solution or code which reproduces the issue label Nov 19, 2024
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-entry Entry platform/android 🤖 s/needs-repro Attach a solution or code which reproduces the issue t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants