sp-dev-fx-controls-react icon indicating copy to clipboard operation
sp-dev-fx-controls-react copied to clipboard

DynamicForm required Fields not checked before submit

Open Khilaar opened this issue 9 months ago • 4 comments

Thank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your needs please complete the below template to ensure we have the details to help. Thanks!

Please check out the documentation to see if your question is already addressed there. This will help us ensure our documentation is up to date.

Category

[ ] Enhancement

[x] Bug

[ ] Question

Version

Please specify what version of the library you are using: ["@pnp/spfx-controls-react": "3.20.0"]

If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.

Expected / Desired Behavior / Question

If you are reporting an issue please describe the expected behavior. If you are suggesting an enhancement please describe thoroughly the enhancement, how it can be achieved, and expected benefit. If you are asking a question, ask away!

When I use the DynamicForm component in my project the form does not get submitted as long as the textfield is empty, which in a sharepoint list is required. With persona Fields this does not work. The Field that does not work is a 'Person or Group' field. It still submits even when the field is required in the sharepoint list but the field in the UI is left empty.

Observed Behavior

If you are reporting an issue please describe the behavior you expected to occur when performing the action. If you are making a suggestion or asking a question delete this section. I think the error happen in DynamicForm.js on line 177. field.newValue is undefined.

This issue seemed to be adressed in version 3.20.0 of "@pnp/spfx-controls-react" but appearently it was not.

Steps to Reproduce

If you are reporting an issue please describe the steps to reproduce the bug in sufficient detail to allow testing. If you are making a suggestion or asking a question delete this section.

Create a list in shrepoint. Try to add a value to a required field (Person or Group field) leave the input field empty and submit the form. It should not submit but it does.

Submission Guidelines

Delete this section after reading

  • All suggestions, questions and issues are welcome, please let us know what's on your mind.
  • Remember to include sufficient details and context.
  • If you have multiple suggestions, questions, or bugs please submit them in separate issues so we can track resolution.

Thanks!

Khilaar avatar Feb 20 '25 16:02 Khilaar

Thank you for submitting your first issue to this project.

github-actions[bot] avatar Feb 20 '25 16:02 github-actions[bot]

Is there any chance someone could give me a heads up here? :)

Khilaar avatar Mar 10 '25 12:03 Khilaar

Hey @Khilaar

I have tried to replicate this issue, I found that the value for an empty user field is [''], and the validation fails when attempting to verify isEmptyArray because the value.length is 1. The following method apparently fails

  private isEmptyArray(value): boolean {
    return Array.isArray(value) && value.length === 0;
  }

I will try to send in a Pull request soon.

//Nish

NishkalankBezawada avatar Mar 11 '25 09:03 NishkalankBezawada

Thank you Nish, I appreciate your work. I will test it in my application as soon as possible

//Khi

Khilaar avatar Mar 11 '25 16:03 Khilaar