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

fix: correct date validation for disabled fields #7240

Merged
merged 2 commits into from
Apr 3, 2024

Conversation

kathleenkhy
Copy link
Contributor

@kathleenkhy kathleenkhy commented Apr 3, 2024

Problem

There is a bug in the validation for dates where if a date field had been input by Respondent 1, and the date violates the validation when it reaches Respondent 2+ (and the fields are disabled), there is still a validation in place that could prevent Respondent 2 onwards from submitting the form

image

Closes FRM-1706

Solution

To remove the validation for disabled fields for Respondent 2 onwards

Breaking Changes

  • No - this PR is backwards compatible

Tests

  • Create an MRF form and add a date field with a validation (eg. prevent past dates)
  • Go to Workflow to create multiple workflows
  • Add the date fields for Workflow 1
  • Add more fields for Workflow 2 onwards
  • Share the form and select a future date - submit the form
  • Open the form for Respondent 2
  • Copy the Submission ID, proceed to the DB and search for the submission ID - change the selected date validation to "selectedDateValidation" : "Disallow future dates"
  • Refresh the page for the MRF form for Respondent 2
  • Fill up the remaining fields in the form and submit as Respondent 2 - you should be able to submit the form

Copy link

linear bot commented Apr 3, 2024

Comment on lines 36 to 45
console.log('disable validaton', disableRequiredValidation)
const validationRules = useMemo(
() => createDateValidationRules(schema, disableRequiredValidation),
[schema, disableRequiredValidation],
)

console.log('validation rules', validationRules)
const { submissionId } = useParams()
console.log('submission id', submissionId)

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this section needed?

Copy link
Contributor Author

@kathleenkhy kathleenkhy Apr 3, 2024

Choose a reason for hiding this comment

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

omg, sorry! 😔 thanks for pointing this out!  🙏🏼

Copy link
Contributor

@justynoh justynoh left a comment

Choose a reason for hiding this comment

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

lgtm

We should open a ticket to investigate this since this behavior is a bit different from other fields

In other field types, we disable the validation only for required-ness, but if an answer exists it must pass the other field validations. Now for the date field, we are disabling all validation completely. I think this is actually okay for all other fields too, since we have backend validation that the non-editable fields were not modified from the backend. we can consider doing this for all the other field types as well.

@kathleenkhy kathleenkhy merged commit d30f62e into develop Apr 3, 2024
21 of 23 checks passed
@kathleenkhy kathleenkhy deleted the fix/mrf-date-validation branch April 3, 2024 14:58
@KenLSM KenLSM mentioned this pull request Apr 3, 2024
26 tasks
KenLSM added a commit that referenced this pull request Apr 4, 2024
* chore(deps-dev): bump @types/express from 4.17.17 to 4.17.21 (#7233)

Bumps [@types/express](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/express) from 4.17.17 to 4.17.21.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/express)

---
updated-dependencies:
- dependency-name: "@types/express"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix(deps): bump nan from 2.17.0 to 2.19.0 (#7212)

Bumps [nan](https://github.com/nodejs/nan) from 2.17.0 to 2.19.0.
- [Changelog](https://github.com/nodejs/nan/blob/main/CHANGELOG.md)
- [Commits](nodejs/nan@v2.17.0...v2.19.0)

---
updated-dependencies:
- dependency-name: nan
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): bump @types/json-stringify-safe from 5.0.0 to 5.0.3 (#7235)

Bumps [@types/json-stringify-safe](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/json-stringify-safe) from 5.0.0 to 5.0.3.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/json-stringify-safe)

---
updated-dependencies:
- dependency-name: "@types/json-stringify-safe"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix(mrf): handling for incorrect submission secret key in url query params (#7219)

* fix: add secret key input mask (#7227)

* fix: add secret key input mask

* fix: add testid to allow storybook to capture inputfield with password type

* fix(mrf): workflow email UI cleanup (#7215)

* fix: mrf workflow email UI cleanup

* chore: update button formatting

* fix: more fixes

* chore: change port for react-email-preview to 4242

* chore: add comment on email defaults

* fix: potentially unsafe external url

* chore(mrf): remove flags (#7230)

chore: remove mrf flag checks

* chore(mrf): add announcement content (#7229)

* chore: add mrf announcement content

* chore: update mrf guide links

* chore: update date to 04-04

* chore: remove exclamation mark after url link

* fix: correct date validation for disabled fields (#7240)

* fix: correct date validation for disabled fields

* fix: removing console logs

* chore: bump version to v6.115.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Justyn Oh <justynoh@gmail.com>
Co-authored-by: Kathleen Koh <89055608+kathleenkhy@users.noreply.github.com>
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.

2 participants