# Hidden data is not removed from redux store

**URL:** <https://jsonforms.discourse.group/t/hidden-data-is-not-removed-from-redux-store/165>\
**Category:** General\
**Created:** [April 29, 2021, 10:58am UTC](https://jsonforms.discourse.group/t/hidden-data-is-not-removed-from-redux-store/165 "2021-04-29T10:58:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [April 29, 2021, 10:58am UTC](https://jsonforms.discourse.group/t/hidden-data-is-not-removed-from-redux-store/165/1 "2021-04-29T10:58:48Z")

</div>

Hi JSONForms community

Im debugging a form of ours that consists of multiple sections. Most of these section starts with a simple yes/no question think of like a toggle button(standard\_main\_question in the schema below).  
The state of the toggle(true or false) is used to show additional questions using the Rules API as written in the docs.

However if I choose to toggle yes and answer those questions but then decide to toggle no.  
Those hidden questions(standard\_main\_question\_additional\_question\_1 and standard\_main\_question\_additional\_question\_2) are still being submitted to the backend and they still remain inside the redux store even though they are now hidden due to I changed my toggle to no.  
I did go through the list of issues on Github and found something related(I think).

> <https://github.com/eclipsesource/jsonforms/issues/1586>
>
> \*\*Describe the bug\*\*
> Using a UI schema rule to disable a group does not disable… the group's contained controls.
> 
> \*\*To Reproduce\*\*
> Steps to reproduce the behavior:
> 1. Create UI Schema with a group containing at least one control.
> 2. Add disable rule to the group
> 3. Trigger the rule and check the control's state
> 4. The control can still be edited
> 
> \*\*Expected behavior\*\*
> The control should be disabled
> 
> \*\*Screenshots\*\*
> If applicable, add screenshots to help explain your problem.
> 
> \*\*Browser (please complete the following information):\*\*
> - Browser \[e.g. chrome, safari\]
> - Version \[e.g. 22\]
> 
> \*\*Used Setup (please complete the following information):\*\*
> - Framework: react
> - RendererSet: vanilla
> 
> \*\*Additional notes\*\*
> Possibly the same problem also applies to other layout renderers and/or hide rules.

I know it can be hard without the actual schema but I can post this here as well. Whats the best way to do so? A gist or directly in the spectrum?

Schema:

{  
“type”: “VerticalLayout”,  
“elements”: [  
{  
“type”: “Section”,  
“label”: “TITLE\_HERE”,  
“description”: “”,  
“elements”: [  
{  
“type”: “ToggleControl”,  
“scope”: “#/properties/standard/properties/standard\_main\_question”  
},  
{  
“type”: “Group”,  
“elements”: [  
{  
“type”: “Control”,  
“scope”: “#/properties/standard/properties/standard\_main\_question\_additional\_question\_1”,  
“options”: {  
“multi”: true  
}  
},  
{  
“type”: “Control”,  
“scope”: “#/properties/standard/properties/standard\_main\_question\_additional\_question\_2”  
}  
],  
“rule”: {  
“effect”: “SHOW”,  
“condition”: {  
“scope”: “#/properties/standard/properties/standard\_main\_question”,  
“schema”: {  
“const”: true  
}  
}  
}  
}  
]  
}

_[[original thread](https://spectrum.chat/jsonforms/general/hidden-data-is-not-removed-from-redux-store~e27652dd-b024-41e5-8bda-22f52d3748ea) by Steffen Thomsen]_

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [May 10, 2021, 7:37am UTC](https://jsonforms.discourse.group/t/hidden-data-is-not-removed-from-redux-store/165/2 "2021-05-10T07:37:12Z")

</div>

Hi @steffen25(steffen25), we don’t remove data by design, we just show or hide the controls. Usually the experience is not that great when the user enters some data, triggers a hide rule (for example by clicking a check box), then untriggers it (unchecking the checkbox) and now has to reenter all of their data again.

Usually I recommend just removing the unwanted data before further processing it, e.g. before sending it to a REST endpoint.

Of course you can still achieve this effect if you want to:

- Register a custom renderer for the control which effectively hides/unhides the other controls. There not only set your own data but also remove the data you don’t want to keep, or

- Register a middleware which listens to these specific data changes you are interested in and also removes the data you don’t want to keep

---

<div class="post-metadata">

**Author:** ![Ollemesh](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/ollemesh/32/1048_2.png) [@Ollemesh](https://jsonforms.discourse.group/u/Ollemesh)\
**Post date:** [June 25, 2024, 4:00pm UTC](https://jsonforms.discourse.group/t/hidden-data-is-not-removed-from-redux-store/165/3 "2024-06-25T16:00:42Z")

</div>

Thank You for the the detailed response.

You said

> I recommend just removing the unwanted data before further processing

I want to filter hidden fields before submitting the form. is it possible?  
Otherwise I cannot understand what data is unwanted.

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [June 26, 2024, 9:13am UTC](https://jsonforms.discourse.group/t/hidden-data-is-not-removed-from-redux-store/165/4 "2024-06-26T09:13:17Z")

</div>

Hi @Ollemesh,

This is not a feature which is currently supported by JSON Forms. We generally avoid manipulating data just by rendering, which is why this feature is not offered.

You could either do a post-processing step yourself to filter all unwanted data, or customize the JSON Forms bindings to adapt the data on the fly when it’s marked `visible: false` by JSON Forms.

Note that this has all kinds of hidden traps, for example if you simply don’t include a field in the UI Schema it will also not shown in the UI and you might expect that it’s also not contained in the data. However as JSON Forms never processed that field in question you will also not get a `visible: false` for it. So in case it was part of the original data passed in to JSON Forms then it will also be there later.
