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

Nested dependency doesn't update #3894

Open
1 task done
Bhirahaspathi-Sairam opened this issue Oct 5, 2023 · 7 comments
Open
1 task done

Nested dependency doesn't update #3894

Bhirahaspathi-Sairam opened this issue Oct 5, 2023 · 7 comments
Labels
feature Is a feature request help wanted

Comments

@Bhirahaspathi-Sairam
Copy link

Prerequisites

What theme are you using?

core

What is your question?

I have a react JSON schema like this

{ "type": "object", "properties": { "platform": { "title": "", "$ref": "#/definitions/platform" } }, "definitions": { "username": { "type": "string", "title": "Enter Username" }, "url": { "type": "string", "title": "Enter url" }, "lineId": { "type": "string", "title": "Enter LineID" }, "platform": { "type": "object", "properties": { "platform": { "type": "string", "title": "Select Platform", "enum": [ "--select--", "Facebook", "Instagram", "Line" ], "default": "--select--" } }, "dependencies": { "action": { "oneOf": [ { "properties": { "action": { "const": "Follow" }, "username": { "$ref": "#/definitions/username" } } }, { "properties": { "action": { "const": "Share" }, "url": { "$ref": "#/definitions/url" } } }, { "properties": { "action": { "const": "Add" }, "lineId": { "$ref": "#/definitions/lineId" } } } ] }, "platform": { "oneOf": [ { "properties": { "platform": { "enum": [ "Facebook" ] }, "action": { "type": "string", "title": "Select Action", "enum": [ "Follow", "Share" ], "enumNames": [ "Follow", "Share" ] } } }, { "properties": { "platform": { "enum": [ "Instagram" ] }, "action": { "type": "string", "title": "Select Action", "enum": [ "Follow" ], "enumNames": [ "Follow" ] } } }, { "properties": { "platform": { "enum": [ "Line" ] }, "action": { "type": "string", "title": "Select Action", "enum": [ "Add" ], "enumNames": [ "Add" ] } } } ] } } } } }

on selecting platform an action field is rendered and based on the action field i am rendering different text fields. After Selecting a platform and action the third text field is displayed, However when i change the platform again the text field is still rendered on the screen .

Is it possible to hide the third field when i re select the platform ?

@Bhirahaspathi-Sairam Bhirahaspathi-Sairam added needs triage Initial label given, to be assigned correct labels and assigned question labels Oct 5, 2023
@heath-freenome
Copy link
Member

heath-freenome commented Oct 6, 2023

Here is a link to the playground with your example. I'm noticing that when you select a different platform, the action data remains, which is why the input field shows up. In the case of changing from Facebook with Follow as a choice to Instagram with Follow as a choice this looks and works fine. But if the value of action is not consistent with the new choice the value remains. One possible work-around to this is to provide an onChange that detects the when the platform changes and removes the action in the formData that is passed back into the Form. There is probably a new feature that needs to be built to handle what to do with formData for this use case.

@Bhirahaspathi-Sairam
Copy link
Author

yes the action field remains.Even though action field is being changed in the ui i.e dropdown , the formdata retains the old action value. Any idea how this can be resolved?

@heath-freenome
Copy link
Member

@Bhirahaspathi-Sairam See my updated comment above

@heath-freenome heath-freenome added awaiting response and removed needs triage Initial label given, to be assigned correct labels and assigned labels Oct 6, 2023
@Bhirahaspathi-Sairam
Copy link
Author

@heath-freenome is this issue will be resolved in the future ?

@magaton
Copy link

magaton commented Oct 12, 2023

I just hit the same problem.
Basically, if the value of the conditional field is changed, every field that was rendered based on that property should be reset, before the condition is evaluated (based on the new selected option).

Is this statement correct? If so, is it something that could be considered as a feature?

I understand that with onChange everything can be manipulated, but this requires hardcoding of field names and custom JS code that pretty much defies the purpose of this library.

@magaton
Copy link

magaton commented Oct 16, 2023

Hello, just to bounce this issue, as it is still unanswered.

@heath-freenome
Copy link
Member

@magaton Yes, this is a new feature request. Thanks for following up. We'd love help building it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is a feature request help wanted
Projects
None yet
Development

No branches or pull requests

3 participants