Xamarin.forms: Android Editor - Text selection menu does not appear when selecting text on an editor placed within a ScrollView

Created on 29 Oct 2019  路  15Comments  路  Source: xamarin/Xamarin.Forms

Description

Cannot get text selection menu to show in Android editor if the editor lives in the following hierarcy:
TabbedPage
---ScrollView
------Editor

Steps to Reproduce

  1. On any Android device, create any layout with an editor placed inside a ScrollView, which lives inside a TabbedPage
  2. Type in some text
  3. Try to select a word by long pressing or double tapping - notice it doesn't show up the text selection menu to be able to copy/paste/select text

Expected Behavior

Show text selection menu when selecting a text on editor.

Actual Behavior

No text selection menu shown when selecting a text on editor inside a ScrollView, which lives inside a TabbedPage

Basic Information

  • Version with issue: 4.0.0.618610 and above
  • Last known good version: 4.0.0.540366
  • IDE: VS 2019 for Windows and Mac
  • Platform Target Frameworks:

    • Android: 9.0

  • Nuget Packages: Xamarin.Forms 4.0.0.540366
  • Affected Devices: All Android devices
  • Possible PR that introduced the issue - #6390

Screenshots

EditorIssue

4.0.0 4 regression in-progress Android bug

Most helpful comment

It looks like this is a bug on the google side

https://issuetracker.google.com/issues/37095917
I added this to our EditorRenderer and it starts to work after that

PR Incoming

In the mean time you can use a custom renderer and copy the code below which should resolve for you

```C#
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();

        EditText.Enabled = false;
        EditText.Enabled = true;
    }

```

All 15 comments

@SachinCS1992 I'm trying to reproduce this issue, but so far I'm not having any luck. In the attached project, I have an Editor inside of a ScrollView, and long press works just fine to select text and pull up the cut/copy/paste menu. Is there some detail I'm missing?

_8291 Repro.zip

@hartez I just tried your repro and compared it against my use case - just noticed that the ScrollView actually needs to be inside a TabbedPage for the issue to occur. I've updated the description above, and also your repro project to replicate the issue and re-uploaded it for your perusal, thanks.
_8291.Repro_modified.zip

@hartez have you had a chance to review updated repro steps from above?

Yep, that updated repro definitely demonstrates this issue.

Also ... that's weird.

Any updates on this? It's causing a lot of frustration and headache for thousands of our customers. Also haven't been able to find a workaround without removing them from under a tabbed page or a scrollview, but it's not feasible in the context/use-case of our applications.

Any updates would be appreciated, thanks.

I'd like to see this fixed too. In my case, the editor parents up to a ContentPage. If I remove the ScrollView in the middle, the issue goes away.

Does it have to do with the fact that the application is listening to 2 types of swipes now and it is blocking the selection gesture as a possible swipe? Vertical swipes for the ScrollView, Horizontal for the Tab switching? Try disabling swipe tab switching and see what happens.

There is no horizontal scrolling or swiping in my case.

No horizontal scroll/swipe in my case either. I think it's the PR I've linked to in the above description is what introduced this issue.

same issue here. Any plan to fix?

I'm using version 4.3.0.908675 of Xamarin Forms Android. After adding scrollview, the copy-paste inside editor stops working. Does anyone have a workaround for this issue?

Example: <ContentPage.Content> <ScrollView> <StackLayout> <Editor HeightRequest="100"></Editor> </StackLayout> </ScrollView> </ContentPage.Content>

I'm facing this issue also..... Is there a work around for this?
Like a custom renderer or something

Anyone interested in fixing the bug?

Seems like the bug should be fixed in this file : https://github.com/xamarin/Xamarin.Forms/blob/bd31e1e9fc8b2f9ad94cc99e0c7ab058174821f3/Xamarin.Forms.Platform.Android/Renderers/ConditionalFocusLayout.cs or here https://github.com/xamarin/Xamarin.Forms/blob/bd31e1e9fc8b2f9ad94cc99e0c7ab058174821f3/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs
There was no changes made there since 2017/2018 so it seems to be an old bug that you just caught. I would just build the project locally and try to see if it hits the Touch breakpoints in those files.

Also, there were changes made in other files related to the Editor / ScrollView, but none of them seemed to cause this issue.

It looks like this is a bug on the google side

https://issuetracker.google.com/issues/37095917
I added this to our EditorRenderer and it starts to work after that

PR Incoming

In the mean time you can use a custom renderer and copy the code below which should resolve for you

```C#
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();

        EditText.Enabled = false;
        EditText.Enabled = true;
    }

```

Was this page helpful?
0 / 5 - 0 ratings