Skip to content

Commit

Permalink
FIO-9202: fixed an issue where the data for the component inside fiel…
Browse files Browse the repository at this point in the history
…dset insdie wizard is lost after submission
  • Loading branch information
TanyaGashtold committed Oct 10, 2024
1 parent bb52a6c commit ea162e4
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 1 deletion.
151 changes: 151 additions & 0 deletions src/process/__tests__/process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3759,6 +3759,157 @@ it('Should not unset values for conditionally visible fields with different form
assert.equal(context.scope.errors.length, 0);
});

it('Should not unset value of the component inside fieldset inside wizard', () => {
const form = {
_id: '67063bc6094b45c5f33ade96',
title: '8802newOne',
name: '8802NewOne',
path: '8802newone',
type: 'form',
display: 'wizard',
owner: '6707a2f60c037c924c716b54',
components: [
{
title: 'Basic & Advanced',
breadcrumbClickable: true,
buttonSettings: {
previous: true,
cancel: true,
next: true,
},
navigateOnEnter: false,
saveOnEnter: false,
scrollToTop: false,
collapsible: false,
key: 'page1',
type: 'panel',
label: 'Page 1',
input: false,
tableView: false,
components: [
{
label: 'Text Field',
description: 'Hide Text Area when Text Field is Empty',
applyMaskOn: 'change',
tableView: true,
validateWhenHidden: false,
key: 'textField',
type: 'textfield',
input: true,
},
{
label: 'Text Area',
applyMaskOn: 'change',
autoExpand: false,
tableView: true,
validateWhenHidden: false,
key: 'textArea',
conditional: {
show: false,
conjunction: 'all',
conditions: [
{
component: 'textField',
operator: 'isEmpty',
},
],
},
type: 'textarea',
input: true,
},
],
},
{
title: 'Advanced & Layout',
breadcrumbClickable: true,
buttonSettings: {
previous: true,
cancel: true,
next: true,
},
navigateOnEnter: false,
saveOnEnter: false,
scrollToTop: false,
collapsible: false,
key: 'page2',
type: 'panel',
label: 'Page 2',
input: false,
tableView: false,
components: [
{
key: 'fieldSet',
type: 'fieldset',
label: 'Field Set',
input: false,
tableView: false,
components: [
{
label: 'Url',
applyMaskOn: 'change',
tableView: true,
validateWhenHidden: false,
key: 'url',
conditional: {
show: true,
conjunction: 'all',
conditions: [
{
component: 'textAreaFieldSet',
operator: 'isEmpty',
},
],
},
type: 'url',
input: true,
},
{
label: 'Text Area - Field set',
description: 'Show URL when Text Area - Field set is empty',
applyMaskOn: 'change',
autoExpand: false,
tableView: true,
validateWhenHidden: false,
key: 'textAreaFieldSet',
type: 'textarea',
input: true,
},
],
},
],
},
],
};

const submission = {
data: { textField: '', textAreaFieldSet: 'test' },
state: 'submitted',
};

const errors: any = [];
const conditionals: any = [];
const context = {
form,
submission,
data: submission.data,
components: form.components,
processors: ProcessTargets.submission,
scope: { errors, conditionals },
config: {
server: true,
},
};

processSync(context);
submission.data = context.data;
context.processors = ProcessTargets.evaluator;
processSync(context);
assert.deepEqual(context.data, { textField: '', textAreaFieldSet: 'test' })
context.scope.conditionals.forEach((cond: any) => {
expect(cond.conditionallyHidden).to.be.true;
})
});

describe('Required component validation in nested form in DataGrid/EditGrid', () => {
const nestedForm = {
key: 'form',
Expand Down
2 changes: 1 addition & 1 deletion src/process/hideChildren.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const hideChildrenProcessor: ProcessorFnSync<ConditionsScope> = (context)
const { component, path, parent, scope } = context;
// Check if there's a conditional set for the component and if it's marked as conditionally hidden
const isConditionallyHidden = scope.conditionals?.find((cond) => {
return path.includes(cond.path) && cond.conditionallyHidden;
return path === cond.path && cond.conditionallyHidden;
});

if (!scope.conditionals) {
Expand Down

0 comments on commit ea162e4

Please sign in to comment.