Skip to content

Happiness Questionnaire shows the missing-reason error above the Submit button instead of under the reason field #1674

Closed

Description

@joshunrau

In the Happiness Questionnaire, the error for a missing dissatisfaction reason is not attached to the reason field. A subject who answers "No" to "Overall, would you say you are satisfied with your life?" and leaves "Why do you feel dissatisfied with your life?" empty cannot submit, and sees "This field is required / Ce champ est obligatoire". The superRefine that raises this error calls ctx.addIssue without a path, so the issue's path is empty. libui's Form (handleError in src/components/Form/Form.tsx) puts every issue with an empty path in rootErrors, which it renders above the Submit button, and the reason field gets no error styling. At that point two empty fields are on screen: the reason and the optional "causes" listbox. The message says "This field" without naming either, so the subject has to guess which one to fill. The dynamic field also returns isRequired: false, which nothing reads and which contradicts the schema.

Where

packages/instrument-library/src/forms/DNP_HAPPINESS_QUESTIONNAIRE/index.ts:172-179:

.superRefine((arg, ctx) => {
  if (!arg.isSatisfiedOverall && !arg.reasonNotSatisfied) {
    ctx.addIssue({
      code: 'custom',
      message: 'This field is required / Ce champ est obligatoire'
    });
  }
})

Reproduce

  1. Administer the Happiness Questionnaire.
  2. Set both sliders and answer "No" to the overall question.
  3. Leave the reason empty and click Submit.

Actual: "This field is required / Ce champ est obligatoire" appears above the Submit button, and the reason field shows no error.
Expected: the error appears under "Why do you feel dissatisfied with your life?", like every other required-field error.

Tests

packages/instrument-library/src/__tests__/DNP_HAPPINESS_QUESTIONNAIRE.test.ts: it('should attach the missing-reason error to reasonNotSatisfied, so the form shows it under that field'). Assert that result.error?.issues[0]?.path equals ['reasonNotSatisfied'].

testing/src/specs/instrument-completion.spec.ts: test('should show the missing-reason error under the reason field when a dissatisfied subject leaves it empty'). Answer "No", leave the reason empty, submit, and expect the error message inside the reasonNotSatisfied field rather than above the Submit button.

Suggested fix

Add path: ['reasonNotSatisfied'] to the addIssue call. Remove the unread isRequired: false from the reasonNotSatisfied field.

Activity

  1. added
    Bug
    Priority: Low
    Difficulty: Low
    Area: Instruments
    Good First Issue
    on Oct 7, 2026
  2. added a commit that references this issue on Oct 29, 2026
    1d7fe73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: InstrumentsBugDifficulty: LowGood First IssuePriority: Low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions