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

Possible bug? #3440

Closed
1 task done
bwied opened this issue Feb 9, 2023 · 8 comments
Closed
1 task done

Possible bug? #3440

bwied opened this issue Feb 9, 2023 · 8 comments

Comments

@bwied
Copy link

bwied commented Feb 9, 2023

Prerequisites

What theme are you using?

core

What is your question?

It seems like validation on the "Live Playground" is no longer working. Could you confirm whether or not you are experiencing the same thing?

@bwied bwied added needs triage Initial label given, to be assigned correct labels and assigned question labels Feb 9, 2023
@bwied
Copy link
Author

bwied commented Feb 9, 2023

It seems as though required field validation is the part that is not working. I apologize if this is something that changed with v5 that is covered in the documentation.

@nickgros
Copy link
Contributor

@bwied which playground examples aren't behaving as expected? To fix #675 and #3424, we've changed how we instantiate formData, which could have broken validation for some of the examples. We'd probably want to fix the examples themselves.

@nickgros nickgros added awaiting response needs triage Initial label given, to be assigned correct labels and assigned and removed needs triage Initial label given, to be assigned correct labels and assigned labels Feb 10, 2023
@bwied
Copy link
Author

bwied commented Feb 10, 2023

@nickgros I was using the simple example and deleting either first name or last name and then clicking submit. It looks like #3424 already covers this issue though, so I'm sorry about that.

The other issue I was seeing is/was related to html5validation and the first invalid input control being out of view when clicking the submit button. This stackoverflow post seems to describe this behavior as more of a browser implementation feature/bug in which the act of scrolling immediately hides the displayed validation popup. I was seeing the same behavior in both Chrome and Edge.

@tyrdavis
Copy link

tyrdavis commented Feb 15, 2023

Seconding this. We're trying to migrate to v5 and required fields never produce validation errors. On the simple example in the playground, you can submit the form without either of the first name or last name fields filled, and neither will ever show an error. Switching to AJV6 validator makes no difference.

@heath-freenome
Copy link
Member

heath-freenome commented Feb 20, 2023

@tyrdavis The reason the simple example validates is because there is an empty string being provided to the formData via the ui:emptyValue prop in the uiSchema so there will always be a valid string. If you remove the ui:emptyValue for say, lastName as shown in this modified simple example, you will see the required field validation occurs. Are you using the ui:emptyValue behavior?

heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Feb 20, 2023
…dation

Issue rjsf-team#3440 describes the required field validation for `firstName` and `lastName` not working for the simple example
- Updated the simple example to remove the `ui:emptyValue` for the `lastName` field so that required field validation works for it.
  - Also added a placeholder for `firstName` indicating that it will never fail validation due to `ui:emptyValue`
@heath-freenome
Copy link
Member

I am updating the simple example to at least make lastName fail the required field validation when nothing is provided.

@heath-freenome
Copy link
Member

heath-freenome commented Feb 20, 2023

@nickgros I was using the simple example and deleting either first name or last name and then clicking submit. It looks like #3424 already covers this issue though, so I'm sorry about that.

The other issue I was seeing is/was related to html5validation and the first invalid input control being out of view when clicking the submit button. This stackoverflow post seems to describe this behavior as more of a browser implementation feature/bug in which the act of scrolling immediately hides the displayed validation popup. I was seeing the same behavior in both Chrome and Edge.

@bwied There is a new feature in 5.1.0 that allows you to select whether the form automatically focuses on the first field with a validation error. Maybe this will help you?

heath-freenome added a commit that referenced this issue Feb 21, 2023
…dation (#3449)

Issue #3440 describes the required field validation for `firstName` and `lastName` not working for the simple example
- Updated the simple example to remove the `ui:emptyValue` for the `lastName` field so that required field validation works for it.
  - Also added a placeholder for `firstName` indicating that it will never fail validation due to `ui:emptyValue`
@bwied
Copy link
Author

bwied commented Feb 22, 2023

@heath-freenome I'm sorry that I overlooked the ui:emptyValue prop, but thank you for updating the sample anyways.

To answer your question, the focusOnFirstError prop did indeed help. I appreciate your follow-up and the continued effort that you and everybody else are putting into this project.

@bwied bwied closed this as completed Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants