Giter VIP home page Giter VIP logo

react-auth-code-input's People

Contributors

dependabot[bot] avatar drac94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

react-auth-code-input's Issues

Able to add more than 1 value to each input

inputs.push(
<input
key={i}
onChange={handleOnChange}
onKeyDown={handleOnKeyDown}
onFocus={handleOnFocus}
onPaste={handleOnPaste}
type={inputType}
ref={(el: HTMLInputElement) => (inputsRef.current[i] = el)}
maxLength={1}
className={inputClassName}
inputMode={inputMode}
autoComplete={i === 0 ? 'one-time-code' : 'off'}
aria-label={
ariaLabel
? `${ariaLabel}. Character ${i + 1}.`
: `Character ${i + 1}.`
}
pattern={i === 0 ? allowedCharacters : ''}
/>

Even though each input has maxLength={1}, I am able to still type in more than 1 value for each input.
This happens:

  1. After you complete all the inputs and continuously try to add more values. The values get appended to the last input.
  2. If you input a value then click and go back to an input and attempt to add other values.

Screen Shot 2022-02-13 at 12 10 42 PM

Allow to send CSS classes for the styling

Each time you inline an object, React re-creates a new reference to this object on every render. This causes components that receive this object to treating it as a referentially different one. Thus, shallow equality on the props of this component will return false on every render cycle.

There are still cases where inline styles can be useful.

Cannot read properties of null (reading 'getData')

Hi, I'm using your library in my project
We have Sentry for monitoring, and recently we started to catch such issues

image

Issue itself is strange, as for Chrome 124.0.0 clipboardData API, according to can-i-use, is supported
I would assume this is custom security options selected by user, or any other strange setup

Anyway, I believe issue can be resolved by adding fallback for clipboardData to navigator.clipboard.readText(), in case clipboardData is unavailable. And adding try-catch block with empty string as fallback, in case API is unavailable for user

async function getPastedValue(e: ClipboardEvent<HTMLInputElement>) {
  try {
    if(e.clipboardData) {
      return e.clipboardData.getData('Text')
    }
    
    if(navigator.clipboard) {
      const pastedValue = await navigator.clipboard.readText();
      
      return pastedValue
    }
    
    return ''
  } catch(e) {
    return ''
  }
}

Check if input is valid length

Hey! Great library.

Would be great to have a helper that knew if the current code is of a valid length.

Example:
— I have a 5 character input code in a form.
— I have a submit button at the bottom of my form.
— I want the button to be disabled unless the user has entered 5 characters.

To be clear, I'm not talking about validating the actual code, just validating the user's input. Basically, unless they've put in the required number of characters, I'd be able to check something like <button disabled={isAuthCodeValidLength}>

Going to probably use a container ref for this in the meantime.

Thanks!

Support for input mode

I would like the be able to specify the inputmode for the inputs themselves. Using this attribute displays the number pad on iOS.

<AuthCode
            characters={6}
            inputMode='numeric'
/>

Add option to disable input

Hi, thank you for great package!

It would be great, if component gave option to disable inputs via prop. I am new to contributing to open source, but will try to help you out!

Prefill input by external values

Hi! Thank you for good package!

I have in my requirements prefilling input by value passed in query params of page.
Component's api right now is "uncontrolled", so we can't pass value to props to render it. And we also don't bind input's state with external state, passed via props. Because of this I don't have any legit way to solve my requirement.

It looks like we could extend ref's api smth like setValue as clearInput.

Add option to clear the input

Hello, I have just integrated this package, and I noticed that there is no way to clear the inputs programmatically. This would be useful as the code that the user types may be invalid and it would help them if they had a "clear" button somewhere on the page instead of manually having to do so.

Numeric input broken on Safari for macOS

I am able to enter non-number values in Safari on macOS, even when allowedCharacters is set to numeric. It looks like when you enter a non numeric value, onChange is not triggered either.

How about a placeholder?

I'd like to add a placeholder character to each input.
It would be good if we can pass true which would render ·(U+00B7) as the default placeholder character
Or pass '*' and it would use that character.

Add support for autocomplete from password managers

You can put <input autocomplete="one-time-password" type="text" inputmode="numeric" pattern="\d*"/> for a 2fa input and you'll get a pretty nice setup as you can see in https://www.twilio.com/blog/html-attributes-two-factor-authentication-autocomplete

It would be nice to add those attributes to improve the UI - I made #27 to show how I think it should work from what I've seen in Slack's TOTP UI, but it looks like you need a bit more JS to hookup and let autocomplete work.

How to style it ?

Hello ! I did not understand how I can style it ? My height is quite small. Thanks a lot for your work.

Can't style inputs

Running React 18 the inputs are not being styled. Now that inputStyle is no more, how can we style the inputs?

image

<AuthCode onChange={(e) => { onChange(e); }} length={6} allowedCharacters="numeric" inputClassName="input" containerClassName='container' />

Add React 17 to Peer Dependencies acceptable Range

I wondered if it would be possible to change the range of React in peer dependencies to include 16 and 17 ?

Happy to open a PR if you are open to it !

In node 16+ we are unable to install this library alongside React 17 without using --force or legacyPeerDeps

Inquiry Regarding Future Updates and Current Status

The last release of this library was a year ago. Are there plans to continue updating it in the future to maintain dependencies and compatibility with newer versions of other libraries? Also, is the reason for the current halt in updates that there have been no critical issues since the last release?

I am considering incorporating this library into my project, so I would appreciate a prompt response.

Arrow key traversal

Added arrow key traversal of inputs, for desktop user friendliness.
Accidentally created an issue. Please delete.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.