google / android-fhir

The Android FHIR SDK is a set of Kotlin libraries for building offline-capable, mobile-first healthcare applications using the HL7® FHIR® standard on Android.
https://google.github.io/android-fhir/
Apache License 2.0
483 stars 283 forks source link

Validation : Initially modal and open choice view shows error message if answer is empty. #1514

Closed santosh-pingle closed 1 year ago

santosh-pingle commented 2 years ago

Describe the bug Modal and open choice view shows error message initially if answer is empty

Component SDC library.

To Reproduce Steps to reproduce the behavior:

  1. Open catalog app.
  2. Click on the Modal view.
  3. Click on the gear icon, it opens the bottom sheet.
  4. Click on the “Show error state”

Expected behavior Initially, it does not show validation error message.

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

Would you like to work on the issue? Please state if this issue should be assigned to you or who you think could help to solve this issue.

jingtang10 commented 2 years ago

i think this should be fixed by #1468 . please verify @santosh-pingle

fredhersch commented 2 years ago

@santosh-pingle can you confirm if this is fixed?

santosh-pingle commented 2 years ago

It's reproducible.

aurangzaibumer commented 2 years ago

https://user-images.githubusercontent.com/35099184/188116008-b3d5212a-eb12-43a6-ab66-4546cc62e126.mp4

Tried this, it is working fine for me (Not showing validation error on start)

Emulator details Pixel 4A Android version 12 sdk_gphone64_x86_64-userdebug 12 SE1A.220203.002.A1 8151367 dev-keys

cc @f-odhiambo

Tarun-Bhardwaj commented 2 years ago

@santosh-pingle , could you please confirm if this is still reproducible?

santosh-pingle commented 2 years ago

Issue is reproducible. Me and @aurangzaibumer already had discussion on it. He already proposed draft, which he supposed to share with @f-odhiambo as per offline discussion with Umer.

jingtang10 commented 2 years ago

@aurangzaibumer do you have any update/ETA for this? thanks

aurangzaibumer commented 1 year ago

@aurangzaibumer do you have any update/ETA for this? thanks

Have investigated the issue and there are two possibilities to solve this problem

  1. to introduce/add a new field on questionnaireItemViewItem that checks if answers is either being modified/add/deleted by the caller. In that way we will able to apply check before calling clearAnswer method. If User has not updated/added/answer in that case we wouldn't call clearAnswer.

  2. to make answers variable in questionnaireitemviewitem nullable and initialize it when answer is either being added/modified/deleted but haven't tried this out because it has a very huge impact on all view factories and its usage is almost on all view factories.

@jingtang10 Please review and suggest which one you think is more suitable.

cc @f-odhiambo

jingtang10 commented 1 year ago

similar to https://github.com/google/android-fhir/blob/4e88f68e1d586d9ad423951cc86d3957fb891c2b/datacapture/src/main/java/com/google/android/fhir/datacapture/views/QuestionnaireItemEditTextViewHolderFactory.kt#L108

i think what you need to do is to make sure if the answer is not validated you don't show any error.

santosh-pingle commented 1 year ago

Looking into it, thanks!