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

Calling KeyboardController.dismiss causes Range Error #684

Closed
vipulbhj opened this issue Nov 13, 2024 · 4 comments · Fixed by #685
Closed

Calling KeyboardController.dismiss causes Range Error #684

vipulbhj opened this issue Nov 13, 2024 · 4 comments · Fixed by #685
Assignees
Labels
🐛 bug Something isn't working

Comments

@vipulbhj
Copy link

Describe the bug
I have a simple component,

<TouchableWithoutFeedback onPress={KeyboardController.dismiss}>
.....
</....>

This is wrapped in KeyboardProvider.

When I run this code, I get

 ERROR  RangeError: Maximum call stack size exceeded, js engine: hermes
[....] RangeError: Maximum call stack size exceeded, js engine: hermes

@vipulbhj vipulbhj changed the title Calling KeyboardController.dismiss causes Range Error. Calling KeyboardController.dismiss causes Range Error Nov 13, 2024
@kirillzyusko
Copy link
Owner

Hello @vipulbhj

KeyboardController.dismiss is a native method (unlike Keyboard.dismiss) and when you do it like {KeyboardController.dismiss} then you are passing additional e which is trying to be serialized and eventually fails to do so 😔

I'll look into what I can do here 👀

@kirillzyusko
Copy link
Owner

As a workaround you can pass () => KeyboardController.dismiss(), but I'll fix it today/tomorrow 👀

@vipulbhj
Copy link
Author

Just looked at the PR, damn, never in my wildest dreams, would I have guessed it's this 😄

Thank you for your work 🙏🏼

kirillzyusko added a commit that referenced this issue Nov 14, 2024
…685)

## 📜 Description

Allow to pass additional params to `KeyboardController.dismiss()` method
unintentionally.

## 💡 Motivation and Context

When we pass params unintentionally like
`onPress={KeyboardController.dismiss}` then we will try to serialize big
JS object to the native side, which eventually crash the application.

To avoid this I decided to wrap `dismiss` in additional function and
always send empty params to a native function.

Closes
#684

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### JS

- removed undocumented `addListener`/`removeListener` methods from
`KeyboardController`;
- allow to pass any params to `dismiss`;
- removed unnecessary functions nesting in `KeyboardToolbar`;

## 🤔 How Has This Been Tested?

Tested on CI.

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
@kirillzyusko
Copy link
Owner

@vipulbhj my pleasure 😊

I'll publish this fix in a new version - in a meantime you can use patch-package to apply changes locally 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
2 participants