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

I encountered that the onStart of useKeyboardHandler on IOS was not triggered #762

Open
zrina1314 opened this issue Jan 18, 2025 · 1 comment
Assignees
Labels
🍎 iOS iOS specific

Comments

@zrina1314
Copy link

I am using iPhone 13, and I often encounter onStart not triggering, so I execute onMove and onEnd.
This problem is occasional, but the probability is high.
Quickly switch between losing focus and gaining focus in the input method, then click on other components, and then click on the text box

Here is my test code

  //#region  
  useEffect(() => {
    const keyboardWillShowListener = Keyboard.addListener('keyboardWillShow', async e => {
      'worklet';
      console.log('__zyf__ 111 keyboardWillShow ', e);
    });
    const keyboardWillHideListener = Keyboard.addListener('keyboardWillHide', e => {
      'worklet';
      console.log('__zyf__ 222 keyboardWillHide ', e);
    });

 
    return () => {
      keyboardWillShowListener.remove();
      keyboardWillHideListener.remove();
    };
  }, []);

  useKeyboardHandler({
    onStart: (e: NativeEvent) => {
      'worklet';
      console.info(`__zyf__ 555 useKeyboardHandler onStart`);
    },
    onMove(e) {
      'worklet';
      console.info(`__zyf__ 666  useKeyboardHandler onMove`);
    },
    onEnd: (e: NativeEvent) => {
      'worklet';
      console.info(`__zyf__ 777 useKeyboardHandler onEnd`);
      console.info(`_____________________________________________________________________`);
    },
  });
  //#endregion

Normal print order:

111 / 222
555
666
777
_______________________________________________________________

Print order in case of exception (555 missing):

111 / 222
666
777
_______________________________________________________________
@kirillzyusko
Copy link
Owner

@zrina1314 a naive fix - can you try to specify [] dependency array to useKeyboardHandler hook? 👀

@kirillzyusko kirillzyusko added the 🍎 iOS iOS specific label Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍎 iOS iOS specific
Projects
None yet
Development

No branches or pull requests

2 participants