maui icon indicating copy to clipboard operation
maui copied to clipboard

Pasting into MAUI text entry does not work on iOS

Open ss-proc opened this issue 3 years ago • 6 comments

Description

Pasting into the MAUI text entry does not work. I have verified that I am able to paste the data into other iOS apps (like messages). See video here:

https://user-images.githubusercontent.com/104405893/192114697-94cf185c-1a30-4410-9dfc-ab7b35fff074.mp4

Steps to Reproduce

Open the Maui samples task app https://github.com/dotnet/maui-samples/tree/main/6.0/Beginners-Series

Or create from scratch

  1. Create new maui app
  2. Add a simple text entry
<Entry x:Name="entry"
       Placeholder="Enter text"
       TextChanged="OnEntryTextChanged"
       Completed="OnEntryCompleted" />
  1. Run the app on iOS
  2. Type something into the text entry
  3. Select and copy the text in the entry
  4. Try to paste it into the text entry

Link to public reproduction project repository

https://github.com/dotnet/maui-samples/tree/main/6.0/Beginners-Series

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 15

Did you find any workaround?

N/A

Relevant log output

N/A

ss-proc avatar Sep 24 '22 19:09 ss-proc

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Sep 28 '22 18:09 ghost

I am also experiencing this issue. Further, in iOS 16, selecting text crashes the application.

christopher-flexteam avatar Oct 04 '22 11:10 christopher-flexteam

Is there no workaround?

PayProff-Don avatar Oct 18 '22 10:10 PayProff-Don

Really is not important that an application crashes when you paste a text in any field?? I have the same problem in iOS 16…

hjam40 avatar Oct 29 '22 10:10 hjam40

So we are now able to paste into the textbox with iOS16. I'm sitting at the in-laws now, so can't verify, but I believe the handler solved it, along with the tapping crash.

#if ANDROID

using AndroidX.AppCompat.Widget;
#elif IOS || MACCATALYST
using UIKit;
#elif WINDOWS
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml;
#endif

namespace PayProff.NativeApp.Controls
{
    /// <summary>
    /// Entry created to ensure similar behavior across platforms
    /// </summary>
    public static class UnifiedEntry
    {
   
        public static void ApplyHandler()
        {
#if IOS
            //Should ensure that tapping the entry multiple times does not crash the app
            Microsoft.Maui.Handlers.EntryHandler.PlatformViewFactory = handler => new WorkaroundMauiTextField();
#endif
        }


    }

#if IOS
    public class WorkaroundMauiTextField : Microsoft.Maui.Platform.MauiTextField
    {
        public WorkaroundMauiTextField() : base()
        {
            //Ensures that the textbox has no border
            BorderStyle = UIKit.UITextBorderStyle.None; //UIKit.UITextBorderStyle.RoundedRect; <-- Part of the original fix
            ClipsToBounds = true;
        }

        [Foundation.Export("selectedTextRange")]
        public new UIKit.UITextRange SelectedTextRange
        {
            get => base.SelectedTextRange;
            set => base.SelectedTextRange = value;
        }
    }
#endif
}

PayProff-Don avatar Oct 29 '22 15:10 PayProff-Don

The same one, but on Windows 11 (Maui Blazor)

sunnamed434 avatar Nov 12 '22 11:11 sunnamed434

How to make custom entry to disable paste option/menu for iOS because in ios16.1.1 pasting on entry causing crashing of app.???

How we can override a method in custom handler like handler.PlatformView.CanPerform()?

Priyabaghelgithub avatar Dec 14 '22 18:12 Priyabaghelgithub

Can anyone confirm this is still an issue? Tried this just now and it seems to work fine for me.

jfversluis avatar Dec 15 '22 13:12 jfversluis

Hi @ss-proc. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

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.

ghost avatar Dec 15 '22 13:12 ghost

What is the command to update dotnet workload ? Cmd= dotnet workload update maui??

On Thu, Dec 15, 2022, 7:13 PM msftbot[bot] @.***> wrote:

Hi @ss-proc https://github.com/ss-proc. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project https://github.com/dotnet/maui/blob/main/.github/repro.md provided through a GitHub repository.

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.

— Reply to this email directly, view it on GitHub https://github.com/dotnet/maui/issues/10302#issuecomment-1353092847, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXFOZJMJTR7H2PA4NZPW2TTWNMOAXANCNFSM6AAAAAAQUYKKXQ . You are receiving this because you commented.Message ID: @.***>

Priyabaghelgithub avatar Dec 15 '22 18:12 Priyabaghelgithub

dotnet workload update maui

dotnet workload update is enough I guess

sunnamed434 avatar Dec 16 '22 11:12 sunnamed434

confirm that on Windows 11 (Maui Blazor) everything is ok now

sunnamed434 avatar Dec 16 '22 11:12 sunnamed434

Solution : Entry pasting issue is fixed after updating to latest .net.

Open the project. Open Developer command prompt. Run the cmd : dotnet workload update Also run cmd : dotnet workload restore Configure net7.0 or latest .Net version in cs.proj file.

Priyabaghelgithub avatar Dec 24 '22 09:12 Priyabaghelgithub