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

Reorganize JS for registration form and add loading indicator #9604

Conversation

rebecca-shoptaw
Copy link
Collaborator

@rebecca-shoptaw rebecca-shoptaw commented Jul 22, 2024

Closes #9603.

Feature. Reorganizes registration validation js to add a loading indicator at the correct point in the validation process and remove the delay between submission and validation.

Technical

Fairly simple! Involved moving the recaptcha info to a div with data-size="invisible" per the recaptcha docs and adjusting the order of the JS checks.

The original grecaptcha.execute() implementation was nested in a click handler rather than a submit handler, as the latter never actually fired, but I'm hoping that now that the recaptcha is no longer linked directly to the submit button a submit handler should work just fine.

Testing

  1. Go to /account/create
  2. Enter badly formatted and/or incomplete data and hit submit (either directly or by hitting enter)
  3. The submit button should remain enabled and you should immediately see an HTML error pop up
  4. Fix the entires and submit again
  5. The submit button should become disabled and replaced with the text "Loading..." and after a couple seconds, the page should refresh

Results of partial GitPod testing:
With the line grecaptcha.execute() replaced with signupForm.submit() since it doesn't work locally:
✅ If all inputs are valid, the submit button becomes a loading indicator and then the page refreshes
✅ HTML errors appear immediately following submit button press, and the submit button does not become a loading indicator

Screenshot

Registration loading indicator

Stakeholders

@cdrini

@codecov-commenter
Copy link

codecov-commenter commented Jul 22, 2024

Codecov Report

Attention: Patch coverage is 22.22222% with 7 lines in your changes missing coverage. Please review.

Project coverage is 17.08%. Comparing base (ce16a79) to head (9cbd068).
Report is 453 commits behind head on master.

Files with missing lines Patch % Lines
openlibrary/plugins/openlibrary/js/signup.js 22.22% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9604      +/-   ##
==========================================
+ Coverage   16.06%   17.08%   +1.02%     
==========================================
  Files          90       89       -1     
  Lines        4769     4730      -39     
  Branches      832      829       -3     
==========================================
+ Hits          766      808      +42     
+ Misses       3480     3412      -68     
+ Partials      523      510      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rebecca-shoptaw rebecca-shoptaw marked this pull request as ready for review July 22, 2024 15:02
@cdrini cdrini self-assigned this Jul 22, 2024
@rebecca-shoptaw rebecca-shoptaw force-pushed the 9603/feature/reorganize-registration-js branch from 843e336 to 20c99b8 Compare July 29, 2024 15:30
@cdrini cdrini added the On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing label Aug 9, 2024
@rebecca-shoptaw rebecca-shoptaw force-pushed the 9603/feature/reorganize-registration-js branch from 20c99b8 to c7cd0c9 Compare September 28, 2024 00:31
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Nice! This makes so much more sense to do this way. All my tests pass!

Test:

  • ✅ Entering a used email shows error
  • ✅ Entering a user username shows error
  • ✅ Hitting submit while error visible does nothing
  • ✅ Entering everything correctly and hitting submit shows loading
  • ✅ Entering everything correctly and hitting submit creates account

With JS Disabled:

  • ✅ Hitting submit while error visible reloads with errors visible
  • 🏳 Entering everything correctly and hitting submit seems to not create an account
    • Pre-existing problem on production page

@cdrini cdrini merged commit e36e0a0 into internetarchive:master Sep 30, 2024
4 checks passed
DanielleInkster pushed a commit to DanielleInkster/openlibrary that referenced this pull request Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
On testing.openlibrary.org This PR has been deployed to testing.openlibrary.org for testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reorganize JS checks for registration form
3 participants