Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Android Editor - Text selection menu does not appear when selecting text on an editor placed within a ScrollView #8291

Closed
SachinCS1992 opened this issue Oct 29, 2019 · 15 comments
Assignees
Labels
4.0.0 regression on 4.0.0 e/4 🕓 4 i/regression in-progress This issue has an associated pull request that may resolve it! p/Android t/bug 🐛
Milestone

Comments

@SachinCS1992
Copy link

SachinCS1992 commented Oct 29, 2019

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 - [Android] refactoring fixes layouts #6390

Screenshots

EditorIssue

@SachinCS1992 SachinCS1992 added s/unverified New report that has yet to be verified t/bug 🐛 labels Oct 29, 2019
@hartez
Copy link
Contributor

hartez commented Oct 31, 2019

@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 hartez added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Oct 31, 2019
@SachinCS1992
Copy link
Author

SachinCS1992 commented Oct 31, 2019

@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

@SachinCS1992
Copy link
Author

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

@samhouts samhouts added p/Android 4.0.0 regression on 4.0.0 i/regression and removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. labels Nov 11, 2019
@hartez
Copy link
Contributor

hartez commented Nov 11, 2019

Yep, that updated repro definitely demonstrates this issue.

Also ... that's weird.

@hartez hartez added e/4 🕓 4 and removed s/unverified New report that has yet to be verified labels Nov 11, 2019
@SachinCS1992
Copy link
Author

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.

@craigwi
Copy link

craigwi commented Dec 15, 2019

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.

@AmrAlSayed0
Copy link

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.

@craigwi
Copy link

craigwi commented Dec 15, 2019

There is no horizontal scrolling or swiping in my case.

@SachinCS1992
Copy link
Author

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.

@LuoyeAn
Copy link
Contributor

LuoyeAn commented Jan 19, 2020

same issue here. Any plan to fix?

@juniorba
Copy link

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>

@IzyPro
Copy link

IzyPro commented Apr 11, 2020

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

@saamerm
Copy link

saamerm commented Apr 13, 2020

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.

@PureWeen PureWeen self-assigned this Apr 21, 2020
@PureWeen
Copy link
Contributor

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

		protected override void OnAttachedToWindow()
		{
			base.OnAttachedToWindow();

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

@PureWeen PureWeen modified the milestones: 4.7.0, 4.6.0 Apr 21, 2020
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Apr 22, 2020
@PureWeen
Copy link
Contributor

Here's a link to the nuget if anyone would like to test this out

https://dev.azure.com/xamarin/public/_build/results?buildId=17360&view=artifacts&type=publishedArtifacts

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4.0.0 regression on 4.0.0 e/4 🕓 4 i/regression in-progress This issue has an associated pull request that may resolve it! p/Android t/bug 🐛
Projects
None yet
Development

No branches or pull requests

10 participants