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

feat(a11y): Remove disabled button from Question component #3149

Merged
merged 3 commits into from
May 16, 2024

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented May 15, 2024

What does this PR do?

  • Enables the "Continue" button by default on all Question components
  • Adds an error message if no option is selected
    • Copy taken from error message of text input

image

Test flow here with all variants of the question component - https://3149.planx.pizza/testing/question-error-test

@DafyddLlyr DafyddLlyr changed the title feat(a11y): Remove disabled button from question component feat(a11y): Remove disabled button from Question component May 15, 2024
Copy link

github-actions bot commented May 15, 2024

Removed vultr server and associated DNS entries

- Add validation for `a`
- Get test functions from `setup()`
- Add `describe()` blocks
@DafyddLlyr DafyddLlyr requested a review from a team May 15, 2024 14:26
@DafyddLlyr DafyddLlyr marked this pull request as ready for review May 15, 2024 14:26
Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

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

Thank you for picking this one up!!

Two small comments/questions before merging, but looks nearly good to go & working as expected on pizza !

validationSchema: object({
selected: object({
id: string().required("Select your answer before continuing"),
a: mixed().required().test(value =>
Copy link
Member

Choose a reason for hiding this comment

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

selected.a can be undefined in initialValues - is it actually required here or optional?

Also nice to see the mixed() syntax in action 💪

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question! I think what I have is correct, as this is a required value at time of submission.

When the component loads the value is not set as it doesn't exist (so it's optional in the props). When navigating "back" it will be set already. The value for selected.a is set alongside selected.id here -

formik.setFieldValue("selected.id", response.id);
formik.setFieldValue("selected.a", response.responseKey);

Copy link
Member

Choose a reason for hiding this comment

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

That distinction makes sense - thanks for clarifying!

container
spacing={layout === QuestionLayout.Basic ? 0 : 2}
alignItems="stretch"
<ErrorWrapper id={`${props.id}-error`} error={formik.errors.selected?.id}>
Copy link
Member

Choose a reason for hiding this comment

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

nit: the ErrorWrapper component already prepends error-message- to whatever id is set here, so no need to explicitly use -error suffix as you have

@jessicamcinchak
Copy link
Member

@DafyddLlyr DafyddLlyr merged commit 4cd9db7 into main May 16, 2024
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/disabled-question-button branch May 16, 2024 07:46
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