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

Validation: Highlight the required fields when a user submits a form #1576

Closed
Itskiprotich opened this issue Aug 31, 2022 · 13 comments · Fixed by #1671
Closed

Validation: Highlight the required fields when a user submits a form #1576

Itskiprotich opened this issue Aug 31, 2022 · 13 comments · Fixed by #1671
Assignees
Labels
effort:medium Medium effort - 3 to 5 days P1 High priority issue type:enhancement New feature or request ux

Comments

@Itskiprotich
Copy link
Contributor

Is your feature request related to a problem? Please describe.
With the SDC beta04, when I try to submit a form with unanswered required fields, it's hard to tell which field is required since the highlight only appears when a user interacts with a specific input field. Is it possible to allow the validators be seen at a glance?

Describe the solution you'd like
Is it possible to have all the required fields marked as shown below in the screenshot?

Describe alternatives you've considered
None
Screenshot_20220831_094028

Additional context

@f-odhiambo
Copy link
Collaborator

This is related #544

@Tarun-Bhardwaj Tarun-Bhardwaj added type:enhancement New feature or request P2 Medium priority issue effort:medium Medium effort - 3 to 5 days and removed To be triaged labels Sep 14, 2022
@jingtang10 jingtang10 added the ux label Sep 22, 2022
@jingtang10
Copy link
Collaborator

can you please share the questionnaire? @Itskiprotich

thanks

@jingtang10 jingtang10 added P1 High priority issue and removed P2 Medium priority issue labels Sep 22, 2022
@jingtang10
Copy link
Collaborator

jingtang10 commented Sep 23, 2022

@Itskiprotich The reason that we do not show all these validation errors is because we do not want to spam the user when they first open the questionnaire. We discussed this with @mberg @f-odhiambo @shelaghm. Showing all these validation errors at the same time when the user first open the questionnaire is considered as an unhelpful pattern.

Unless there's a differernt solution, I will just mark this as a duplicate issue as #544 as @f-odhiambo suggested.

EDIT: please feel free to reopen if you have additional comments or disagree.

@jingtang10
Copy link
Collaborator

@Itskiprotich can you confirm if you can use the submit button provided by the library (which uses the fragment results API)? rather than calling the getQuestionnaireResponse API?

Discussed with @aditya-07 and @shelaghm. It remains a question what the questionnaire behavior should be when there are either validation errors on the last page, or previous pages (in the case of random entry mode, you can navigate to the next page without having completed everything in the current page, so it's possible that when you're on the last page, there're still unanswered questions in previous pages). Should we have a pop-up dialog? an inline widget? a toast? or some kind of more flexible API for developers to provide feedback to the user however they like.

@shelaghm
Copy link

I think a pop-up dialog that is displayed when a user presses "submit" can work well here because we want to alert people take action and fix the issues. There should also be error messages already displayed in the form if they haven't completed required questions or there's validation errors.

Screenshot w/ example
Screen Shot 2022-09-28 at 16 25 27

What do you think of this approach @aditya-07 and @jingtang10?

@shelaghm
Copy link

shelaghm commented Oct 5, 2022

Discussion with Jing:
What happens when you complete fields -> scroll back to the first incomplete question (single page) or first page for paginated
Should we also add a OK/Save anyways button? (use case is for saving a draft of a questionnaire)
V1 of this could be to only show an OK button here, and V2 could be to add complete fields button.

How to show the questionnaire has fields that are incomplete in the patient card?

@Itskiprotich
Copy link
Contributor Author

Sorry for the delay.

Attached is the questionnaire I'm using.
baby-monitoring.zip

@jingtang10
Copy link
Collaborator

i think in the V1 we should have "complete fields" and "submit anyway" buttons in the dialog just because in some cases the healthworker might want to save a draft questionnaire

@jingtang10
Copy link
Collaborator

@shelaghm i think the text in the dialog needs to be more generic. "complete all required fields" doesn't cover the cases where validation is failing for other reasons, e.g., value too large/small, text too long/short etc.

@shelaghm
Copy link

shelaghm commented Nov 29, 2022

@jingtang10 How about some of these options? Is incomplete questionnaire generic enough? I was thinking it could cover both the scenario of missing questions or that there are errors causing the questionnaire to be incomplete. Another option (3) is to describe all of it as "errors" without making a distinction of what kind of error it is. Thoughts?

Screen Shot 2022-11-29 at 15 50 28

@shelaghm
Copy link

shelaghm commented Nov 30, 2022

Aligned on this direction with Jing. Fix the following questions
Screen Shot 2022-11-30 at 08 17 57

@jingtang10
Copy link
Collaborator

@shelaghm nit: let's use anyway instead of anyways since anyways is the informal version of anyway.

@shelaghm
Copy link

shelaghm commented Dec 3, 2022

@jingtang10 sounds good, I'll make the change in my mocks
@aditya-07 please use "save anyway" when working on this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:medium Medium effort - 3 to 5 days P1 High priority issue type:enhancement New feature or request ux
Projects
Status: Complete
Development

Successfully merging a pull request may close this issue.

7 participants