-
Notifications
You must be signed in to change notification settings - Fork 6
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
[Task] [User Profile] useRef in Step1FormErrorHeader #145
[Task] [User Profile] useRef in Step1FormErrorHeader #145
Conversation
Changes: - utilized useRef in Step1FormErrorHeader to focus an error element
@@ -152,11 +153,10 @@ function Step1Form(): JSX.Element { | |||
// https://github.com/cfpb/sbl-frontend/issues/135 | |||
await auth.signinSilent(); | |||
window.location.href = '/landing'; | |||
// navigate('/landing') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// navigate('/landing') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the issue is solved, navigating should done this way. Using window.location.href
causes a hard refresh.
I'm keeping the comment here since it will eventually be uncommented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
When there are errors upon clicking Submit
, would it make sense to focus on the "There was a problem completing your profile" box that lists all of the errors? That way users get the overview of what needs to be corrected before they will be able to proceed.
Good thinking. I will add this to this PR. |
@meissadia Added an additional UX of a smooth scrolling to the error heading after hitting the submit button (if there are errors). Please re-review and focus that part of this PR. |
…ser-profile-header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shindigira I've pulled the latest but the app is crashing:
I don't see errorFormReference
defined anywhere in the project.
@meissadia Removed that. Should work now! Thanks for the catch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some great stuff in here @shindigira!
I don't want to hold up this PR, but the "useRef" part you've added still uses document.querySelector
when creating the ref, instead of a declarative approach using refs. The react-hook-form
documentation has an example on their FAQ page that they recommend for scrolling an input into view that uses the declarative ref approach.
https://www.react-hook-form.com/faqs/#Howtosharerefusage
I don't want to hold up this PR, and there's more code to write with this approach, but when I think about using refs declaratively, this is the kind of approach I was imagining.
That approach you linked is not dynamic by having to manually declare each ref top-level. Could keep an array or map object of refs (e.g. |
I think I'd prefer it then if you just go back to using |
Reverted; and I agree about avoiding imperative code. |
…o 102-useref-user-profile-header
…o 102-useref-user-profile-header
…o 102-useref-user-profile-header
…o 102-useref-user-profile-header
* refactor: Utilized DSR AlertFieldLevel in NoDatabaseResultError * refactor: created a const for the sblhelp link * refactor: InputEntry utilizes DSR's TextInput * refactor: Utilized DSR AlertFieldLevel in InputErrorMessage * dev: placed a way to destroy the login creds during development * refactor: auto-format * chore: removed import * refactor: Utilized TextIntroduction in Step1FormHeader and resolved TS errors in Associated * fix: RSSD not RSS * chore: changed type to null * chore: changed TAX ID to TIN * feat: email text instead of disabled input * style: adjusted spacing styles on User Profile * chore: added TODO * refactor: updated content text to the figma * chore: added TODO comment * styling: updated Checkbox, 01-09-24 Figma updates to spacing and content text * styling: additional spacing changes * style: px to rem button group * chore: updated to latest DSR package * fix: disabled user name and LOG OUT during profile-form view * comment: indicated workaround for red checkbox border * style: removed input border under red border during an error * chore: remove unused classes * style: updated content text, removed App.less * style: fixed tailwind overriding styles by removing @tailwind directives * style: fixed tailwind overriding styles by removing @tailwind base directive * chore: updated denied email notification based on figma * style: uses the listlink in the step1formerrorheader * style: moved error within well * style: small em to rem fix * style: style mt fix * fix: merge conflicts * style: style updated spacings * style: spacing 2 * fix: removed unused variable * [Task] [User Profile] useRef in Step1FormErrorHeader (#145) * feat: utilized useRef in Step1FormErrorHeader Changes: - utilized useRef in Step1FormErrorHeader to focus an error element * fix: lint errors * chore: moved function to profileformutils * feat: added back scroll animation to step1formerrorheader * chore: remove unused useref * fix: removed unused var * refactor: added type to submitprofile * chore: pulled in 85 and fixed merge conflicts * fix: resolved conflicts 2 * revert: reverted to document.querySelector use * fix: resolved merge conflicts * style: fix gray/red border * style: remove periods from error header text * chore: removed class attribute * chore: package fix * chore: CFPB package update * chore: updated content text - checkbox well
close #102
Changes
How to Test
Complete your Use Profile
click the submit buttonScreenshot