gluestack-ui icon indicating copy to clipboard operation
gluestack-ui copied to clipboard

onKeyPress in <InputField /> triggers additional "Backspace" event after each key press (except for backspace itself)

Open chkee opened this issue 1 year ago • 1 comments

Description

onKeyPress in <InputField /> should be triggered according to what you actually press, and backspace key shouldn't be triggered unless pressed

CodeSandbox/Snack link

No response

Steps to reproduce

Steps to reproduce:

Have following implementation:

<Input>
    <InputField
        onKeyPress={({nativeEvent}) => {
            console.log(`InputField-onKeyPress: ${nativeEvent.key}`, { nativeEvent });
        }}/>
</Input>

Case 1: Non backspace keys

  1. Type in "12ab" alphabets/number.
  2. Observe the log, there would be 8 logs (instead of 4), each keys were followed by a Backspace that you didn't pressed. image

Case 2: Backspace key

  1. Now try press "Backspace" once.
  2. Observe the log, there's only one log from the backspace. Which is the expected behavior. image

gluestack-ui Version

1.0.36

Platform

  • [ ] Expo
  • [X] React Native CLI
  • [ ] Next
  • [ ] Web
  • [ ] Android
  • [X] iOS

Other Platform

No response

Additional Information

Note: This has happened to me on iOS, I haven't tested on Android yet.

chkee avatar Jan 19 '24 23:01 chkee

hi @chkee, I tried to reproduce the issue that you hae reported but it's working fine for me. I am sharing below the reference of my git repo https://github.com/rajat693/rn-inputBox

rajat693 avatar Jan 29 '24 10:01 rajat693

I am closing this issue for now. If you need further assistance or if the problem persists, please don’t hesitate to reopen it. Thank you!

rajat693 avatar Aug 06 '24 05:08 rajat693