Skip to content

UX improvements to the one-time-code field - #1

Open
goulvench wants to merge 1 commit into
tapster:mainfrom
goulvench:patch-1
Open

goulvench wants to merge 1 commit into
tapster:mainfrom
goulvench:patch-1

Conversation

@goulvench

Copy link
Copy Markdown

Small UX improvements

  • autocomplete: "one-time-code" allows browsers like Safari to automatically suggest OTPs received in SMS and emails. https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#sect16
  • autofocus: true opens the virtual keyboard automatically on mobile, and helps keyboard users on desktop too
  • pattern: [a-z0-9] allows browsers to adapt the virtual keyboard on mobile, and to validate before sending the form on mobile and desktop.

You could even go the extra mile and add a stimulus controller to strip whitespace, in case the user copies spaces or newlines along with the code.

In know this repo is only for demo purpose, but thought I'd share these quick UX wins antway because we'd all be better off if all devs knew about them :-)

Small UX improvements

- `autocomplete: "one-time-code"` allows browsers like Safari to automatically suggest OTPs received in SMS and emails.
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#sect16
- `autofocus: true` opens the virtual keyboard automatically on mobile, and helps keyboard users on desktop too
- `pattern: [a-z0-9]` allows browsers to adapt the virtual keyboard on mobile, and to validate before sending the form on mobile and desktop.

You could even go the extra mile and add a stimulus controller to strip whitespace, in case the user copies spaces or newlines along with the code.
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.

1 participant