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

transformForSubmit strips non-empty showPagePerItem pages #140

Closed
markgreenburg opened this issue Jul 5, 2018 · 3 comments
Closed

transformForSubmit strips non-empty showPagePerItem pages #140

markgreenburg opened this issue Jul 5, 2018 · 3 comments
Assignees
Labels
[practice] engineering Engineering related work

Comments

@markgreenburg
Copy link

markgreenburg commented Jul 5, 2018

What Happens
transformForSubmit filters out data from active pages when the properties of those pages match properties in schemas of other inactive pages - even though properties are required to match across these pages due to them having been created with showPagePerItem using the common property as the arrayPath.

How to Reproduce

  1. Set up a form page with an array schema definition:
disabilities: {
  type: 'array',
  maxItems: 100,
  items: {
    type: 'object',
    properties: {...}
  }
}
  1. Set up two other pages using showPagePerItem, with the original page as the arrayPath:
evidenceType: {
  path: 'supporting-evidence/:index/evidence-type',
  showPagePerItem: true,
  itemFilter: (item) => _.get('view:selected', item),
  arrayPath: 'disabilities',
  uiSchema: {...},
  schema: {
    type: 'object',
    properties: {
      disabilities: {...}
      ...
    }
  }
},
vaMedicalRecordsIntro: {
  path: 'supporting-evidence/:index/va-medical-records-intro',
  showPagePerItem: true,
  itemFilter: (item) => _.get('view:selected', item),
  arrayPath: 'disabilities',
  uiSchema: {...},
  schema: {
    type: 'object',
    properties: {
      disabilities: {...}
      ...
    }
  }
}
  1. Fill out the form such that at least one of the two child pages is 'inactive'
  2. Transform data using transformForSubmit:
const formConfig = {
  ...
  transformForSubmit
  ...
};

Result:
formData that's returned from transformForSubmit lacks a disabilities property

Why?
us-forms-system/src/js/helpers.js
The problem happens within transformForSubmit:

  • transformForSubmit calls getInactivePages, which will put all inactive pages into an array
  • then filterInactivePages(pages, form) gets called with this inactive page list
  • One of the inactive pages will have disabilities as a property
  • disabilities will be stripped from the form data
  • This happens despite the fact that some other active pages have a disabilities property with data on it

Expected behavior
Properties on inactive pages are not stripped if they're also found in active pages.

Possible Solution

  • Keep a list of properties belonging to active pages
  • Check the properties getting removed against the list of properties known to belong to active pages
  • Only remove a property from form data if its page is inactive AND it's not on the list of active page properties.

Additional context

  • vets.gov Form 526 can't submit form data without this bug getting addressed. This is blocking integration testing for us.
@annekainicUSDS annekainicUSDS self-assigned this Jul 6, 2018
@annekainicUSDS annekainicUSDS added the [practice] engineering Engineering related work label Jul 6, 2018
@annekainicUSDS
Copy link
Contributor

Working on recreating this issue. The Vets.gov team is not completely blocked for now; they've implemented a temporary workaround in their own codebase.

@annekainicUSDS
Copy link
Contributor

PR to resolve this issue is open: #155

@markgreenburg
Copy link
Author

Thanks Anne! Yep, was able to test out your PR locally and the issue seems to be resolved, using the same data with which we were previously having trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[practice] engineering Engineering related work
Projects
None yet
Development

No branches or pull requests

2 participants