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

[Entry] [Android] Cursor makes undesired jumps with masked behaviour #13571

Closed
Asfiroth opened this issue Feb 26, 2023 · 7 comments
Closed

[Entry] [Android] Cursor makes undesired jumps with masked behaviour #13571

Asfiroth opened this issue Feb 26, 2023 · 7 comments
Labels
area-controls-entry Entry platform/android 🤖 s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Milestone

Comments

@Asfiroth
Copy link

Asfiroth commented Feb 26, 2023

Description

Using the .NET MAUI Entry control works fine in both android and iOS, but applying behaviours such as MaskedBehvior from .NET MAUI Community Toolkit (or others) ends up un randomic cursor movements on Android, iOS doesn't present this strange behaviour.

Steps to Reproduce

  1. Create a MAUI App.
  2. Download package CommunityToolkit.Maui and follow instructions to make it work.
  3. On Main page put a entry with behaviour:
<Entry>
                <Entry.Behaviors>
                    <mtc:MaskedBehavior Mask="XXXX XXXX XXXX XXXX" />
                </Entry.Behaviors>
            </Entry>
  1. Start writing and see randomic cursor dance.

Link to public reproduction project repository

https://github.com/Asfiroth/MauiEntryBehaviourIssue

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12 and up

Did you find any workaround?

Yes, modifying the Entry handler for android adding this:

On ConnectHandler:

PlatformView.TextChanged += PlatformViewOnTextChanged;

On DisconnectHandler:

PlatformView.TextChanged -= PlatformViewOnTextChanged;

This is the event handler for text changed event

private void PlatformViewOnTextChanged(object sender, TextChangedEventArgs e)
    {
        if (sender is not AppCompatEditText editText) return;
        
        if (string.IsNullOrWhiteSpace(editText.Text)) return;
        
        var looper = Looper.MyLooper();
        if (looper != null)
        {
            var handler = new Handler(looper);
            handler.Post(() =>
            {
                editText.SetSelection(editText.Text.Length);
            });
        }else
        {
            editText.SetSelection(editText.Text.Length);
        }
    }

It's not perfect but does the job, any help to make this better is appreciated.

Relevant log output

No response

@Asfiroth Asfiroth added the t/bug Something isn't working label Feb 26, 2023
@Asfiroth Asfiroth changed the title [Entry] Cursor makes undesired jumps with masked behaviour [Entry] [Android] Cursor makes undesired jumps with masked behaviour Feb 26, 2023
@rmarinho
Copy link
Member

This should be fixed by #12750 . The fix should be in net8-preview1

@jfversluis can you test maui main with the CommunityTolkit ?

@rmarinho rmarinho added this to the Backlog milestone Feb 27, 2023
@ghost
Copy link

ghost commented Feb 27, 2023

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.

@rmarinho rmarinho added area-controls-entry Entry partner/android Issues for the Android SDK labels Feb 27, 2023
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Feb 27, 2023
@rmarinho rmarinho added platform/android 🤖 s/try-latest-version Please try to reproduce the potential issue on the latest public version and removed partner/android Issues for the Android SDK labels Feb 27, 2023
@ghost
Copy link

ghost commented Feb 27, 2023

Hi @Asfiroth. 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.

@Asfiroth
Copy link
Author

Asfiroth commented Feb 27, 2023

This should be fixed by #12750 . The fix should be in net8-preview1

Hi @rmarinho would that fix make it to net7-latest version?

@rmarinho
Copy link
Member

rmarinho commented Feb 27, 2023

The bar for net7 fixes is high now, but i will suggest as backport and we will discuss on our team meeting.

But if you can confirm it works on net8 it will be great. Thanks

@Phantom-KNA
Copy link

I have the same issue, i hope work on net.8

@ghost
Copy link

ghost commented Mar 30, 2023

Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 30, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-entry Entry platform/android 🤖 s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants