Closed suleymanbariseser closed 1 year ago
@suleymanbariseser, thanks for working on this. I think this code block is also not needed anymore, because this was added in v2 just to handle this case I believe
Will give it a run, can you also check if any other cases in the handleKeyDown
method need this as well?
@suleymanbariseser Were you able to make the changes here?
@prateek3255 sorry for the delay, I checked it and it seems this condition does not work also;
else if (event.key === otp[activeInput]) {
event.preventDefault();
focusInput(activeInput + 1);
}
However, I think it is not possible to solve this problem by checking event object because keyCode is always 229 and key is "Unidentified"
Okay what could be the possible solution here?
I think instead of comparing current value and pressed key, it would be better having a fallback condition which will move cursor to next input because it does not even work if I press a different key (on desktop browser) when I am focused at the end of the current input.
It does not work because handleChange will be triggered with a value like "xc" and isInputValueValid will return as false so it will not move forward.
if (isInputValueValid(value)) {
changeCodeAtFocus(value);
focusInput(activeInput + 1);
}
This bug is also raised in react thanks for the solution @suleymanbariseser. Please merge this pr as soon as possible. Need to make patch for the same.
Yeah you are right @suleymanbariseser when the input is selected, key and keyCode are unidentified and 229 respectively. So we'll have to figure out a different way handle this. But this PR at least partially solves the problem by selecting the last input on backspace. So bringing this in for the time being will open another issue for handling that edge case
@all-contributors please add @suleymanbariseser for bug
@prateek3255
I've put up a pull request to add @suleymanbariseser! :tada:
What does this PR do? Fixes #388
Any background context you want to provide? In android, event.code has no value if user click backspace. However, event.key has "backspace" value so instead of just checking event.code, event.key also must be checked.
Screenshots and/or Live Demo![Screenshot 2023-03-26 at 12 17 32](https://user-images.githubusercontent.com/50797736/227766641-7f9862ae-ebfc-47df-aeda-e0b41609b65b.png)