kirillzyusko / react-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android
https://kirillzyusko.github.io/react-native-keyboard-controller/
MIT License
1.38k stars 55 forks source link

[iOS only] [v1.12] `onFocus` event is only called on first focus on TextInput #456

Closed christophemenager closed 3 weeks ago

christophemenager commented 1 month ago

Describe the bug

To Reproduce Steps to reproduce the behavior:

  1. Add a TextInput centered in a View on iOS (react-native 0.73.8)
  2. Click on the input, onFocus is called
  3. Click outside, onBlur is called
  4. Click on the input again: nothing happens (onFocus is NOT called)

Expected behavior onFocus and onBlur events should be called everytime the input is focused or blurred

Smartphone (please complete the following information):

Additional context This regression has been introduced in 1.12, 1.11 is working fine

kirillzyusko commented 1 month ago

Hey @christophemenager

Can you post a minimal reproduction code, please? I've used this code:

export default function AwareScrollView({ navigation }: Props) {
  return (
    <>
      <ScrollView style={{flex: 1,}} contentContainerStyle={{paddingLeft: 100, flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: "red"}}>
        <TextInput
          key={1}
          placeholder={`TextInput#${1}`}
          keyboardType={1 % 2 === 0 ? "numeric" : "default"}
          multiline={false}
          onFocus={() => console.log("onFocus")}
          onBlur={() => console.log("onBlur")}
          style={{borderWidth: 2, borderColor: "black"}}
        />
      </ScrollView>
    </>
  );
}

But it always calls onFocus/onBlur whenever I press on input/press outside:

 LOG  onFocus
 LOG  onBlur
 LOG  onFocus
 LOG  onBlur
 LOG  onFocus
 LOG  onBlur
 LOG  onFocus
 LOG  onBlur

I tested in RN 0.74 - do you think it makes a difference?

kirillzyusko commented 1 month ago

I also tested RN 0.73.4 (old architecture) - still everything works okay 🤷‍♂️ Guess something wrong with my code that I'm using 🤔

kirillzyusko commented 1 month ago

@christophemenager I've also tested on iPhone 6s (iOS 15.8) and I can not reproduce this problem in example app (I used Toolbar screen as example).

May I ask you to test my example app and maybe perform some code modifications to show how it can be reproduced?

The issue seems to be quite critical, so I want to fix it ASAP, but I can not reproduce it 😔

Please, don't ignore me 🙏

christophemenager commented 1 month ago

Sorry I am a bit busy this week, can I get back to you next Monday? I will try to give you a minimal repro code :)

kirillzyusko commented 1 month ago

Sorry I am a bit busy this week, can I get back to you next Monday?

Yeah, sure, take your time 👍

I will try to give you a minimal repro code :)

Thank you ❤️

christophemenager commented 3 weeks ago

Hi there! Sorry for the delay.

I tried to reproduce in an isolated react-native environment but I could not.

I guess it must be very specific to my setup, so I will close this issue and reopen it if I find a way to reproduce it properly.

kirillzyusko commented 3 weeks ago

@christophemenager yes, feel free to re-open this 👍

In 1.12 version I started to inject my own delegate to intercept some events that are available only on delegate level. So I guess in some scenarios delegate substitution doesn't work properly, so it would be good if you could figure out and provide a repro 🙏