Page MenuHomePhabricator

[web][native] Trimming whitespaces from username at login screen
ClosedPublic

Authored by przemek on Oct 14 2022, 3:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 27, 9:06 PM
Unknown Object (File)
Sun, Nov 24, 12:40 PM
Unknown Object (File)
Sun, Nov 24, 12:40 PM
Unknown Object (File)
Sun, Nov 24, 12:40 PM
Unknown Object (File)
Sun, Nov 24, 12:40 PM
Unknown Object (File)
Sun, Nov 24, 12:40 PM
Unknown Object (File)
Sun, Nov 24, 12:40 PM
Unknown Object (File)
Sat, Nov 23, 7:16 AM

Details

Summary

Solving this issue: https://linear.app/comm/issue/ENG-2041/[web]-[native]-bug-whitespaces-arent-trimmed-from-right-side-of

Added onBlur event listener to username field so whenever it goes out of focus, it is trimmed.
It goes out of focus whenever we swap fields or click submit button, so it works.

On native we simply trim whitespaces whenever user types them as blur events aren't handled in a same way (input field doesn't go out of focus when we click submit button, so there's no good place for trimming it)

Mobile:

Web:

Test Plan

Build application.
Tested scenarios manually.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ashoat requested changes to this revision.Oct 14 2022, 5:39 AM
ashoat added inline comments.
web/account/log-in-form.react.js
97 ↗(On Diff #17566)
  1. This change doesn't have anything to do with this diff, so it should be in its own diff
  2. We should make sure we're consistent across all error messages like this (eg. in registration as well) if we're making this change
  3. I'd like to see a visual comparison of lowercase / uppercase here if we want to make this change, to make sure it looks better
136 ↗(On Diff #17566)

By defining this function inline you're causing it to be recalculated on every render. Instead, it should be defined using React.useCallback

This revision now requires changes to proceed.Oct 14 2022, 5:39 AM

Updating D5365: [web][native] Trimming whitespaces from username at login screen

Yeah, you're right, we should be consistent in our error messages. Sorry for that. I reversed that change.
Also added useCallback.

Thanks for sharing a video with your test!! I was going to suggest testing if onBlur triggered before the submit if you pressed the button after having the username input focused, but I can see you already tested that :)

tomek added inline comments.
web/account/log-in-form.react.js
55 ↗(On Diff #17571)

It seems like this line isn't necessary so it's safer to delete it. (we should use invariants only when really necessary).

This revision is now accepted and ready to land.Oct 14 2022, 8:06 AM
This revision was landed with ongoing or failed builds.Oct 14 2022, 8:59 AM
This revision was automatically updated to reflect the committed changes.