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

useKeyboardHandler height onMove is not updated when switching to Emoji on iOS #600

Closed
kimak opened this issue Sep 26, 2024 · 3 comments
Closed
Assignees
Labels
🍎 iOS iOS specific question You wanted to clarify something about the usage of the library or have a question about something

Comments

@kimak
Copy link

kimak commented Sep 26, 2024

Describe the bug
When switching the Keyboard in Emoji mode the height useKeyboardHandler onMove event is not updated.

Code snippet

  useKeyboardHandler(
    {
      onMove: (event) => {
        'worklet'
        height.value = Math.max(event.height, 0)
      },
    },
    []
  )

Repo for reproducing
Here a simple snack example https://snack.expo.dev/@kimak/keyboard-emoji
Let me know if you need a reproducible repo.

To Reproduce
Steps to reproduce the behavior:

  1. Open the keyboard on iOS input
  2. Switch the keyboard in emoji
  3. The height is not updated

Expected behavior
When switching to emoji the height of the keyboard should update

Screenshots:
Working example
Screenshot 2024-09-26 at 23 17 58

Issue
Screenshot 2024-09-26 at 23 18 29

Smartphone (please complete the following information):

  • Device: iPhone SE
  • OS: iOS 17
  • RN version: 0.72
  • JS engine: Hermes
  • Library version: 1.3.4
@kirillzyusko
Copy link
Owner

@kimak the onMove handler is supposed to be called only during the animation frame. In your case the transition is instant and there are literally 0 animation frames, so onMove is not getting called.

To assure that shared value is always synchronized with keyboard position you should always use onEnd handler.

So in your case the code should be:

useKeyboardHandler(
    {
      onMove: (event) => {
        'worklet'
        height.value = Math.max(event.height, 0)
      },
      onEnd: (event) => {
        'worklet'
        height.value = Math.max(event.height, 0)
      },
    },
    []
  )

Did I answer in the question?

@kimak
Copy link
Author

kimak commented Sep 27, 2024

Yes perfectly, it's fixed now:
Screenshot 2024-09-27 at 09 24 29

thanks a lot for your works on this 🙇‍♂️

@kimak kimak closed this as completed Sep 27, 2024
@kirillzyusko
Copy link
Owner

You are welcome @kimak 😊

@kirillzyusko kirillzyusko added question You wanted to clarify something about the usage of the library or have a question about something 🍎 iOS iOS specific labels Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍎 iOS iOS specific question You wanted to clarify something about the usage of the library or have a question about something
Projects
None yet
Development

No branches or pull requests

2 participants