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

omitExtraData drops value of field whose identifier contains a dot "." #2643

Closed
3 tasks done
JakobEdding opened this issue Jan 5, 2022 · 2 comments · Fixed by #3203
Closed
3 tasks done

omitExtraData drops value of field whose identifier contains a dot "." #2643

JakobEdding opened this issue Jan 5, 2022 · 2 comments · Fixed by #3203
Labels

Comments

@JakobEdding
Copy link

JakobEdding commented Jan 5, 2022

Prerequisites

Description

See playground example

When omitExtraData is enabled, rjsf drops the value of a nested field for which the identifier contains a dot ., submit. This is unexpected behavior. In case the fields are also required, this leads to failure of form submission down the road. You can see this if you open the example and submit the form right away.

Note that the value of level.1.property seems to not be dropped, so there it works as expected.

Might be related to #2036

Steps to Reproduce

See playground example (same as above)

  1. Turn on "omit extra data"
  2. Add an object to the schema and another object as child.
  3. Add a required field with name level.2.property and type string to the lower-level object from before.
  4. Fill in dummy values in the form.
  5. Submit the form.

Expected behavior

Form is submitted without errors.

Actual behavior

Form submission fails, field level.2.property is marked as required indicating that its value is empty.

Version

3.2.1

@v1ack
Copy link
Contributor

v1ack commented Oct 3, 2022

still actual for version 5

@v1ack
Copy link
Contributor

v1ack commented Oct 3, 2022

How it works now:

  1. Form.getFieldNames gets a list of valid paths, ["dict1.field", "dict.2.field"]
  2. Form.getUsedFormData uses loadash.pick to get values with paths from p.1 from formData

As I understood, we can fix it by making Form.getFieldNames return string[][] instead of string[], lile [["dict1", "field"], ["dict.2", "field"]]
It's valid for loadash.pick sources, but invalid for loadash.pick type annotations
@heath-freenome what do you think?

v1ack added a commit to v1ack/react-jsonschema-form that referenced this issue Oct 19, 2022
heath-freenome added a commit that referenced this issue Oct 26, 2022
* fix omit field names with dot #2643

* add type casting

Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants