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

onChange/onComplete events not triggered when a not valid key is pressed #16

Closed
sclavijo93 opened this issue Mar 27, 2020 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@sclavijo93
Copy link

If I complete the pin field and then I go to the first or any field that is filled and press one of these keys (ArrowUp[38], ArrowDown[40], ContextMenu[93], Esc[27], or whatever key that is not valid with this regex /^[0-9]$/) the content of that field is deleted. Is this intended? Also, the onchange event is not triggered

I think that is better if the pushed key is not valid, that field should stay untouched. Or maybe that could be configurable via a prop? deleteWhenNotValid or whatever, it's just a brainstorming

Code example:

codesandbox.io

Steps to reproduce:

  • Fill the pin fields
  • Go to a field that is filled
  • Press a letter or an arrow (Up or Down)
  • The field is deleted but the onChange/onComplete event is not triggered.
  • The current code and completed rows are not updated

Environment

Tech Version
Browser Chrome Version 80.0.3987.149 (Official Build) (64-bit)
react 16.13.0
react-pin-field 1.0.2
@sclavijo93 sclavijo93 changed the title onChange/onComplete events not triggered when press a not valid key onChange/onComplete events not triggered when a not valid key is pressed Mar 27, 2020
@soywod
Copy link
Owner

soywod commented Mar 27, 2020

You right, it makes more sense to keep the field untouched when a key is rejected. I don't think a prop is needed, since the behaviour can be simulated inside the onRejectKey. I will fix ASAP. Or feel free to propose a PR :)

@soywod soywod self-assigned this Mar 27, 2020
@soywod soywod added the bug Something isn't working label Mar 27, 2020
soywod added a commit that referenced this issue Mar 28, 2020
@soywod
Copy link
Owner

soywod commented Mar 28, 2020

Fixed in v1.0.3 [diff] 🎉

@soywod soywod closed this as completed Mar 28, 2020
@soywod soywod removed their assignment Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants