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

Auto select TOTP input contents when focused #166

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

adamwoodnz
Copy link
Contributor

@adamwoodnz adamwoodnz commented May 18, 2023

Closes #155

This PR builds upon the paste handler added in #154

When an input is focused its contents are automatically selected, allowing the user to use Tab to move back and forth and type over previous values.

totp auto select

How to test

Combinations of typing values, tabbing forwards and backwards, pasting, delete with backspace, clear all.

@adamwoodnz adamwoodnz self-assigned this May 18, 2023

if ( value && '' !== value.trim() && inputRef.current.nextElementSibling ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change handler is now only responsible for updating the input values

( event ) => onChange && onChange( event.target.value, event, index, inputRef ),
[]
);
handler && handler( event.target.value, event, index, inputRef.current );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think the consumer needs to know about the ref, we can just pass the current value back

@adamwoodnz adamwoodnz requested review from iandunn and dd32 May 18, 2023 04:37
@adamwoodnz adamwoodnz added enhancement New feature or request ui Related to user interface labels May 18, 2023
@adamwoodnz adamwoodnz modified the milestones: Iteration 2, Iteration 1 May 18, 2023
Copy link
Member

@dd32 dd32 left a comment

Choose a reason for hiding this comment

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

This works well in my testing, except, when multiple keys are pressed before the keyUp event happens.

For example, type 123123 by pressing 2 before 1 comes up, and 3 before 2 comes up and you'll see a "sluggish" UI that doesn't currently occur that misses some key presses.

Pastes still work as expected, and I'm not sure this is a real-life example that needs to be worried about, but you'll see the effect I mean if you try it..

trunk PR
Screen.Recording.2023-05-18.at.2.55.42.pm.mov
Screen.Recording.2023-05-18.at.2.54.46.pm.mov

@adamwoodnz
Copy link
Contributor Author

I'm not sure this is a real-life example that needs to be worried about, but you'll see the effect I mean if you try it..

Yeah if you're a fast typer, and especially using a the numeric keypad, I can see it being potentially frustrating. Thanks, I'll see if I can improve it.

@adamwoodnz
Copy link
Contributor Author

type 123123 by pressing 2 before 1 comes up, and 3 before 2 comes up and you'll see a "sluggish" UI that doesn't currently occur that misses some key presses

I think this should be fixed now @dd32

@adamwoodnz adamwoodnz force-pushed the add/paste-in-totp branch from aa2afe3 to 345c6c4 Compare May 23, 2023 00:21
@adamwoodnz adamwoodnz force-pushed the enhance/155-totp-select-input-on-tab branch from 562db78 to 5c374b3 Compare May 23, 2023 00:21
Base automatically changed from add/paste-in-totp to trunk May 23, 2023 02:52
@adamwoodnz adamwoodnz requested a review from dd32 May 23, 2023 03:13
@dd32
Copy link
Member

dd32 commented May 23, 2023

@adamwoodnz Better :) I'm starting to question this though, because this is downright kind of crazy..

  • Can't overwrite first field
  • fast typing doesn't always overwrite
  • At this point this seems like this isn't reasonable to fix :)
Screen.Recording.2023-05-23.at.4.32.17.pm.mov

@adamwoodnz
Copy link
Contributor Author

  • Can't overwrite first field
  • fast typing doesn't always overwrite

Hmm let me have another look

@renintw
Copy link
Contributor

renintw commented May 24, 2023

Can't overwrite first field
fast typing doesn't always overwrite

I've also run into these two issues. Additionally, there's another change that I find has become less convenient. Now when deleting digits, it needs continuously pressing backspace to tab backward, while originally it could be done by just holding the key down.

@StevenDufresne StevenDufresne removed this from the Iteration 1 milestone Jun 2, 2023
@StevenDufresne StevenDufresne added this to the Iteration 2 milestone Jun 2, 2023
@StevenDufresne StevenDufresne removed this from the Iteration 2 milestone Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ui Related to user interface
Projects
Status: Draft (PR only)
Development

Successfully merging this pull request may close these issues.

TOTP Codes should auto-select any contents upon tab
4 participants