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

[MDCT-1959] Clear nested fields after they are hidden from view #4125

Merged
merged 16 commits into from
Oct 4, 2022

Conversation

juliuscaesar
Copy link
Contributor

@juliuscaesar juliuscaesar commented Sep 29, 2022

Description

Closes MDCT-1959: Nested fields shouldn't persist data in form state or save to database
Also fixes what I assume were some incorrect validation types and removes a comma-separated mask on a textarea.
Note: this doesn't really work for fields that are already persisted to the database. Don't worry, it's fine. We'll address that when we do autosave 😬

How to test

  • After filling out a nested field, unselect (for a checkbox) or change the parent value (radio) to hide the nested field. Then reselect the original parent value and ensure the nested field does not display what you entered previously.
  • For textarea nested under checkbox: Section B, Encounter Data Report
  • For textarea nested under radio: Section B, Program Integrity
  • For radio nested under checkbox: Section B, Encounter Data Report
  • For number nested under radio: Section D, Program Integrity
  • For date nested under radio: Section D, Quality Measures

Changed Dependencies

N/A

Code author checklist

  • I have performed a self-review of my code
  • I have added thorough tests
  • I have added analytics, if necessary
  • I have updated the documentation, if necessary

Reviewer checklist (two different people)

  • I have done the deep review and verified the items in the above checklist are g2g
  • I have done the lgtm review

Copy link
Contributor

@gmrabian gmrabian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clears things out and I don't see them in the database! However I'm also seeing an issue with saving to the database in general from the program integrity page. I see it on main too, so likely unrelated, but I can't be sure this isn't saving to the db until I know what's causing that

@ntsummers1

This comment was marked as resolved.

Copy link
Contributor

@braxex braxex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me.

@ntsummers1 I agree it's a little odd that the fields remaining in the database, but we don't currently have a method for deleting individual fields from the database. Once they're set, they're set. They don't hurt anything by being there so I figure we're good.

services/ui-src/src/components/fields/ChoiceListField.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@gmrabian gmrabian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing an issue where nested fields aren't rehydrating

Screen.Recording.2022-09-29.at.2.04.02.PM.mov

Copy link
Contributor

@gmrabian gmrabian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I typed in a nested text field, changed my outermost radio to no (so all nested fields didn't show) but the nested text value still save and shows up if I open that one again
saved like this:
Screen Shot 2022-09-29 at 2 20 04 PM

come back to page and click yes, yes
Screen Shot 2022-09-29 at 2 20 08 PM

db has value as we
Screen Shot 2022-09-29 at 2 21 08 PM
ll

Copy link
Contributor

@gmrabian gmrabian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😌

Copy link
Contributor

@braxex braxex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't had a chance to check out the functionality myself, but leaving some thoughts on the method because of the CodeClimate cognitive complexity warning.

services/ui-src/src/components/fields/ChoiceListField.tsx Outdated Show resolved Hide resolved
services/ui-src/src/components/fields/ChoiceListField.tsx Outdated Show resolved Hide resolved
services/ui-src/src/components/fields/ChoiceListField.tsx Outdated Show resolved Hide resolved
services/ui-src/src/components/fields/ChoiceListField.tsx Outdated Show resolved Hide resolved
@juliuscaesar juliuscaesar merged commit 4917888 into main Oct 4, 2022
@juliuscaesar juliuscaesar deleted the mdct-1959 branch October 4, 2022 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants