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

Cursor skipping back while start typing a value in numeric field #1914

Open
owais-vd opened this issue Mar 16, 2023 · 7 comments · Fixed by #1922 · May be fixed by #2537
Open

Cursor skipping back while start typing a value in numeric field #1914

owais-vd opened this issue Mar 16, 2023 · 7 comments · Fixed by #1922 · May be fixed by #2537
Assignees
Labels
P1 High priority issue

Comments

@owais-vd
Copy link
Collaborator

Describe the bug
Cursor is skipping back while start typing on the numeric field if the initial value is set to 0

Component
SDC library

To Reproduce
Steps to reproduce the behavior:

  1. Go to any questionnaire.
  2. Click on any field that has a support number only.
  3. Type a 0 first.
  4. Then type any number like 100 after 0.
  5. You'll notice that the cursor is back to the second last character instead of the end.

Expected behavior
Cursor should stick to the end position of the field.

Screenshots

device-2023-03-16-144134.mp4

Smartphone (please complete the following information):

  • Device: emulator
  • Android version: 11
  • Build number: RSR1.201013.001
@omarismail94
Copy link
Contributor

I can replicate this! Interesting bug for sure. Ill look into this some more

@omarismail94
Copy link
Contributor

Found the issue. When we go to update the UI, we do a text comparison of the answer saved in the ViewModel vs what is on the screen. If they are different, we update the UI with the text from the ViewModel.

When a user types in "01", that is saved as "1" in the ViewModel, so when UI does the comparison, it sees these as different and updates the UI with 1. This happens here":

https://github.com/google/android-fhir/blob/master/datacapture/src/main/java/com/google/android/fhir/datacapture/views/factories/EditTextIntegerViewHolderFactory.kt#L68-L71

To fix that, we can do an int comparison instead:

        if ((text?.toIntOrNull() != textInputEditText.text.toString().toIntOrNull())) {
          textInputEditText.setText(text)
        }

I tried this and it worked. I need to add test cases, and once I do, Ill push a PR out

@f-odhiambo
Copy link
Collaborator

This issue seems to be reoccurring again cc @omarismail94

@jingtang10 jingtang10 reopened this Oct 5, 2023
@jingtang10 jingtang10 reopened this Oct 5, 2023
@jingtang10
Copy link
Collaborator

@f-odhiambo please assign this to someone thanks!

@MJ1998 MJ1998 added the P1 High priority issue label May 2, 2024
@AngelaKabari
Copy link

@MJ1998 please find here a screen recording of the cursor skipping bug on emulator, along with the emulator bug report.

Let me know if you require any further information or clarification?

@karina4050
Copy link

karina4050 commented May 3, 2024

@MJ1998 Screen recording of the bug on the SID Bunda app.
Device: Emulator Pixel 2 API 29
Android Version: 10
Build Number: QSR1.190920.001

Screen_recording_20240503_125603.webm

@MJ1998
Copy link
Collaborator

MJ1998 commented May 6, 2024

Thanks. Looking into this

@MJ1998 MJ1998 linked a pull request May 8, 2024 that will close this issue
7 tasks
@MJ1998 MJ1998 self-assigned this May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 High priority issue
Projects
Status: New
7 participants