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

LF-4272 trim sign-up name whitespace #3395

Merged
merged 3 commits into from
Sep 4, 2024

Conversation

kevin-wu01
Copy link
Collaborator

@kevin-wu01 kevin-wu01 commented Aug 26, 2024

Description

Previously, when the user tries to create an account with leading spaces in the name field it would cause an error on creation. The issue has been fixed by trimming any leading spaces in the field on blur.

Jira link

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have added "MISSING" for all new language tags to languages I don't speak
  • I have added the GNU General Public License to all new files

@kevin-wu01 kevin-wu01 self-assigned this Aug 27, 2024
@kevin-wu01 kevin-wu01 marked this pull request as ready for review August 27, 2024 21:07
@kevin-wu01 kevin-wu01 requested review from a team as code owners August 27, 2024 21:07
@kevin-wu01 kevin-wu01 requested review from Duncan-Brain and SayakaOno and removed request for a team August 27, 2024 21:07
Copy link
Collaborator

@SayakaOno SayakaOno 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 working on this!
I think we typically trim strings on the backend using the checkAndTrimString utility function, so we should do the same here. (@Duncan-Brain please correct me if I'm wrong!)

@Duncan-Brain
Copy link
Collaborator

Good call @SayakaOno forgot all about that -- if that fixes it too that would be more robust. Could also do both FE and BE for visual input correctness in which case the trimStart() on the FE makes sense too while keeping it fully trimmed on BE!

@kevin-wu01
Copy link
Collaborator Author

kevin-wu01 commented Sep 1, 2024

Thanks for the suggestions, I added the backend trimming for consistency. However, after looking at it some more, there is a regex in the frontend here that was causing the issue. It splits the Full Name field on whitespace, which means any leading whitespace causes an empty string first_name to be sent to the API.

I found the same bug on the invite user to farm page and checked Google SSO out of curiosity too, but Google thankfully trims whitespace in names. The combined full name field seems to make handling the data a bit awkward.

Copy link
Collaborator

@Duncan-Brain Duncan-Brain left a comment

Choose a reason for hiding this comment

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

Awesome thank you for finding that second instance!

@SayakaOno has gone on holiday so I will request the second reviewer from @kathyavini

Copy link
Collaborator

@kathyavini kathyavini left a comment

Choose a reason for hiding this comment

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

The combined full name field seems to make handling the data a bit awkward.

Yeah, I think it has definitely come up in discussion before whether this is the right way to be doing it!

Thank you @kevin-wu01, it looks great!

@kathyavini kathyavini added this pull request to the merge queue Sep 4, 2024
Merged via the queue into integration with commit 4aaa10a Sep 4, 2024
5 checks passed
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.

4 participants