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

Removing properties from schema (as demonstrated in "conditional fields" example) does not remove field from rendered form #638

Closed
2 tasks done
LyraelRayne opened this issue Jul 18, 2017 · 8 comments

Comments

@LyraelRayne
Copy link
Contributor

LyraelRayne commented Jul 18, 2017

Prerequisites

  • I have read the documentation;
  • In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.

Description

Removing a property from (a clone of) the schema does not remove the field from the form

Steps to Reproduce

  1. Open the "conditional fields" example linked to from the project page (https://jsfiddle.net/69z2wepo/68259/)
  2. Tick the box to cause the "Name" field to be displayed
  3. Untick the box

Expected behavior

The name field should disappear

Actual behavior

The name field doesn't disappear

Version

0.49.0

@Natim
Copy link
Contributor

Natim commented Jul 18, 2017

I guess it is because you are adding it if it is checked but no removing it if it is unchecked.

@Natim
Copy link
Contributor

Natim commented Jul 18, 2017

@n1k0 n1k0 closed this as completed Jul 18, 2017
@LyraelRayne
Copy link
Contributor Author

I didn't write the code, it's an example from https://github.com/mozilla-services/react-jsonschema-form#tips-and-tricks (so I presumed that it was meant to work as-is).

The code example does actually remove them, but it does it by mutating the schema.properties instead of replacing it with a modified clone.

https://jsfiddle.net/69z2wepo/83018/ is a working version of the original example. I would suggest that you guys update the example link to the fixed version.

@Natim
Copy link
Contributor

Natim commented Jul 18, 2017

@LyraelRayne would you like to send a pull-request with that modification?

@LyraelRayne
Copy link
Contributor Author

LyraelRayne commented Jul 18, 2017

I'm not really sure how to go about that (never done one on github). Do I have to make a fork or something?

EDIT: Worked it out :)

@LyraelRayne
Copy link
Contributor Author

Quick question: Do I have to keep the fork around once the pull request is merged?

@Natim
Copy link
Contributor

Natim commented Jul 18, 2017

Nope :)

@LyraelRayne
Copy link
Contributor Author

Thanks. That was all a lot less scary than it seemed ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants