soywod / react-pin-field

📟 React component for entering PIN codes.
https://soywod.github.io/react-pin-field/
MIT License
413 stars 24 forks source link

Auto trigger Tab on complete #8

Closed soywod closed 4 years ago

bluepioupiou commented 4 years ago

do you want me to try this one and adding a e2e test since it's working ?

soywod commented 4 years ago

With great pleasure :) I didn't search yet how to manage this. The idea is once you completed this PIN code field, it triggers a tab to jump to the next field (for example, in a form with other fields).

soywod commented 4 years ago

I searched a lot, and I wasn't able to find a solution. I even posted on Stack Overflow - without success. So I will close this issue. This behaviour still can be done manually using the onComplete event:

const nextControlRef = useRef<HTMLInputElement>()

// ...
function handleComplete() {
  if (nextControlRef.current) {
    nextControlRef.current.focus()
  }
}

// ...
<PinField onComplete={handleComplete} />
<input ref={nextControlRef} />