Skip to content

Commit

Permalink
Bug: multiple exposed fields in a section causes context to be overwr…
Browse files Browse the repository at this point in the history
…itten (#1288)

* Replaced Object.assign with a hoek.merge to make sure nested values aren't overwritten

* Modified ContextComponent.getFormDataState to always return an object to avoid merge undefined error

* Updated html templating example form to have both questions in the same section

* Updated upload artifact action to v4
  • Loading branch information
ziggy-cyb committed Sep 12, 2024
1 parent 9b67204 commit 95b1d6d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ jobs:
run: yarn ${{inputs.workspace}} test-cov

- name: Upload test results artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: ${{ success() || failure() }}
with:
name: test-results-${{inputs.workspace}}
path: ${{inputs.workspace}}/test-results
retention-days: 14

- name: Upload test coverage artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: ${{ success() || failure() }}
with:
name: test-coverage-${{inputs.workspace}}
Expand Down
3 changes: 2 additions & 1 deletion e2e/cypress/fixtures/html-templating-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"schema": {}
}
],
"next": [{ "path": "/summary" }]
"next": [{ "path": "/summary" }],
"section": "gcdSFb"
},
{
"title": "Summary",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ export class ContextComponent extends FormComponent {

if (name in state) {
_.set(result, `${path}${name}`, this.getFormValueFromState(state));
return result;
}

return undefined;
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { ComponentCollection } from "server/plugins/engine/components/ComponentC
import { FormModel } from "server/plugins/engine/models";
import { FormSubmissionState } from "server/plugins/engine/types";
import { FormComponent } from "server/plugins/engine/components/FormComponent";
import { reach } from "@hapi/hoek";
import _ from "lodash";
import { merge } from "@hapi/hoek";
import { ContextComponent } from "server/plugins/engine/components/ContextComponent";
import { ComponentBase } from "server/plugins/engine/components/ComponentBase";

Expand Down Expand Up @@ -34,7 +33,7 @@ export class ContextComponentCollection extends ComponentCollection {
const formData = {};

this.items.forEach((item: ContextComponent) => {
Object.assign(formData, item.getFormDataFromState(state));
merge(formData, item.getFormDataFromState(state));
});

return formData;
Expand Down

0 comments on commit 95b1d6d

Please sign in to comment.