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(Form + GridForm): Add actual required optional + required form text #2872

Merged
merged 48 commits into from
May 29, 2024

Conversation

dreamwasp
Copy link
Contributor

@dreamwasp dreamwasp commented Apr 30, 2024

Overview

Adds * Required to GridForm (and as a FormElement) + (optional) to labels of optional field. Also removed showRequired from GridForm because the accessibility text is mandatory

Theres also some reorganizing of form elements into folders

PR Checklist

  • Related to designs: here
  • Related to JIRA ticket: [gm-620]
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

  1. Check out GridForm page
  2. See the form additions
  3. Turn on screenreader
  4. See that (optional) and * in form fields are not read

PR Links and Envs

Repository PR Link PR Env
Mono Monolith PR [Monolith Env]

@dreamwasp dreamwasp changed the title reorg form elements feat(Form): Add actual required optional + required text May 7, 2024
@dreamwasp dreamwasp marked this pull request as ready for review May 7, 2024 21:30
@dreamwasp dreamwasp requested a review from a team as a code owner May 7, 2024 21:30
@dreamwasp dreamwasp changed the title feat(Form): Add actual required optional + required text feat: Add actual required optional + required text May 8, 2024
@dreamwasp dreamwasp changed the title feat: Add actual required optional + required text feat: Add actual required optional + required form text May 8, 2024
Copy link
Contributor

@aresnik11 aresnik11 left a comment

Choose a reason for hiding this comment

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

It works!! ✨

Copy link
Contributor

@LinKCoding LinKCoding left a comment

Choose a reason for hiding this comment

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

LGTM! Left some comments and questions :)
Tested the voiceover on required and optional text and they're not read :D

{showRequired ? ' *' : ''}
{!isSoloField && (
<Text as="span" aria-hidden>
{required ? '*' : ' \u00A0(optional)'}
Copy link
Contributor

Choose a reason for hiding this comment

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

' \u00A0

is the space before the \u00A0 intentional?
When looking up \u00A0, I see it's a non-break space, so to me, this reads as two spaces. But then, it looks like the tests pass, and the stories look fine 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i was having issues when not including the hardcoded space but I'll double check!

Copy link
Contributor

Choose a reason for hiding this comment

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

definitely one of those things where I'm more curious than anything lol


export function GridForm<Values extends FormValues<Values>>({
cancel,
children,
columnGap = defaultColumnGap,
fields = [],
hasSoloField = false,
hideRequiredText,
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be defaulted to false?

@@ -24,6 +27,8 @@ export const GridFormContent: React.FC<GridFormContentProps> = ({
field.validation?.required
);

// console.log(isSoloField);
Copy link
Contributor

Choose a reason for hiding this comment

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

leftover comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ty!! will fix!

@@ -34,6 +34,8 @@ The primary access pattern of `ConnectedForm` is the `useConnectedForm` hook whi

Each of your fields' names must correspond with the appropriate `defaultValue` key. `validationRules` operates similarly - each key must correspond to a key in `defaultValue` and must follow [react-hook-form's](https://react-hook-form.com) [validation patterns](https://react-hook-form.com/v6/api#register).

This hook also returns the `FormRequiredText` component - include this before your form unless all of your form fields are optional.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a form where all fields are optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yupp! a good example is the job-readiness page -- all of the fields are optional (you do need one of them to submit the form but it can be any one of them)


## hideRequiredText

`hideRequiredText` will hide the ;\* Required' text that appears at the top of our forms. This should only be hidden if the form has no required fields.
Copy link
Contributor

Choose a reason for hiding this comment

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

;* Required'

typo, the semicolon should be a single quote

@codecademydev
Copy link
Collaborator

📬Published Alpha Packages:

eslint-plugin-gamut@2.1.1-alpha.4bbe1f.0
@codecademy/gamut@55.20.1-alpha.4bbe1f.0
@codecademy/gamut-icons@9.24.3-alpha.4bbe1f.0
@codecademy/gamut-illustrations@0.45.2-alpha.4bbe1f.0
@codecademy/gamut-kit@0.6.409-alpha.4bbe1f.0
@codecademy/gamut-patterns@0.9.13-alpha.4bbe1f.0
@codecademy/gamut-styles@16.2.2-alpha.4bbe1f.0
@codecademy/gamut-tests@5.0.11-alpha.4bbe1f.0
@codecademy/styleguide@66.20.1-alpha.4bbe1f.0

@codecademydev
Copy link
Collaborator

🚀 Styleguide deploy preview ready!

https://66574521a00be628a46251b1--gamut-preview.netlify.app

Deploy Logs

@dreamwasp dreamwasp added the Ship It :shipit: Automerge this PR when possible label May 29, 2024
@codecademydev codecademydev merged commit e712b44 into main May 29, 2024
17 of 18 checks passed
@codecademydev codecademydev deleted the cass-gm-620 branch May 29, 2024 15:28
@codecademydev codecademydev removed the Ship It :shipit: Automerge this PR when possible label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants