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

Delay after keyboard dismissed #341

Closed
rcb4t2 opened this issue Mar 29, 2022 · 2 comments · Fixed by #342
Closed

Delay after keyboard dismissed #341

rcb4t2 opened this issue Mar 29, 2022 · 2 comments · Fixed by #342

Comments

@rcb4t2
Copy link
Contributor

rcb4t2 commented Mar 29, 2022

Is your feature request related to a problem? Please describe.
I'm always frustrated when the Toast is triggered near the same time as the keyboard is dismissed. The Toast tends to hang up at the keyboard offset position even after the Keyboard has gone away

Describe the solution you'd like
A prop to opt out of automatic keyboard handling. isKeyboardAware: boolean would be great

Describe alternatives you've considered
Currently we have to setTimeout with a 600ms delay so the Toast will wait until the Keyboard is gone

Additional context
Thanks for the component! Works great besides the keyboard issue

@rcb4t2
Copy link
Contributor Author

rcb4t2 commented Mar 29, 2022

Edit: We updated to the latest version, and the Toast now correctly jumps back down when the keyboard is dismissed. However, it still starts up at the offset location and then jumps down, looks awkward

Our code looks something like this

function onSubmit () {
  Keyboard.dismiss();
  callApi()
    .then(() => {
      Toast.show()
    }
}

@rcb4t2
Copy link
Contributor Author

rcb4t2 commented Mar 29, 2022

@calintamas I was able to fix this bug by updating the useSlideAnimation hook

Wrapping translateY with useMemo fixes it (putting keyboardHeight and the other values in the dependency array)

const translateY = React.useMemo(() => animatedValue.current.interpolate({
        inputRange: [0, 1],
        outputRange: translateYOutputRangeFor({
            position,
            height,
            topOffset,
            bottomOffset,
            keyboardHeight,
            keyboardOffset
        })
    }), [position, height, topOffset, bottomOffset, keyboardHeight, keyboardOffset]);

@rcb4t2 rcb4t2 changed the title Opt out of automatic Keyboard handling Delay after keyboard dismissed Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant