Skip to content

Commit

Permalink
Fix that backspace doson't remove selected digit in the VerificationC…
Browse files Browse the repository at this point in the history
…odeControl

Address #1003
  • Loading branch information
eason9487 committed Sep 10, 2021
1 parent 305c21c commit 2188f60
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ export default function VerificationCodeControl( {
};

const handleKeyDown = ( e ) => {
const { dataset, selectionStart, value } = e.target;
const { dataset, selectionStart, selectionEnd, value } = e.target;
const idx = Number( dataset.idx );

switch ( e.keyCode ) {
case KEY_CODE_LEFT:
case KEY_CODE_BACKSPACE:
if ( selectionStart === 0 ) {
if ( selectionStart === 0 && selectionEnd === 0 ) {
maybeMoveFocus( idx - 1 );
}
break;
Expand Down

0 comments on commit 2188f60

Please sign in to comment.