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

Focusing on input of GiftedChat #2548

Open
anauk opened this issue Oct 21, 2024 · 5 comments
Open

Focusing on input of GiftedChat #2548

anauk opened this issue Oct 21, 2024 · 5 comments

Comments

@anauk
Copy link

anauk commented Oct 21, 2024

Issue Description

On screen with GiftedChat, when try to open a modal with an input field, the focus remains on the input field of the GiftedChat. How can put cursor and tipping on input in Modal?
I tried to use: if (inputRef.current) {
inputRef.current.blur(); // Blur the input manually
} for input of GiftedChat, but i doesn't help

Steps to Reproduce / Code Snippets

on screen with GiftedChat set up listener which shows Modal with input if need it. When Modal appears and i want white in input, keyboard appears but i don't see where i'm typing. When i close Modal i see that it was typing in input of GiftedChat.

Expected Results

If Modal was opened i can typing in input of Modal

Additional Information

  • Nodejs version: 18.20.4
  • React version: 18.2.0
  • React Native version: 0.74.3
  • react-native-gifted-chat version: ^2.6.4
  • Platform(s) (iOS, Android, or both?): both
@danilvalov
Copy link
Contributor

I missed this issue and created an issue with the same problem.
So I copy my researching results to this issue to have more detailed view.

Very interesting bug with useAnimatedReaction hook.

This hook works globally for keyboard on all screens, so if GiftedChat was rendered and we keep it in memory then any keyboard opening calls handleTextInputFocusWhenKeyboardShow callback that tries to focus on GiftedChat TextInput. And it breaks all TextInputs in apps.

Steps to Reproduce / Code Snippets

  1. (optional) Use @react-navigation in your app (with setting to keep rendered screens in app memory)
  2. Add <GiftedChat /> to the second screen of your app
  3. Add some another <TextInput /> to the first screen of your app
  4. Open your app and focus on your <TextInput /> on the first screen
  5. Touch some place out of the this text input (it works correctly, keyboard is hide)
  6. Open the second screen with GiftedChat (to render this component first time)
  7. Open the first screen with <TextInput /> again
  8. Touch some place out of the this text input (it works incorrect already, keyboard is show anyway)

@danilvalov
Copy link
Contributor

danilvalov commented Dec 23, 2024

There is not any way to fix it without injections to <GiftedChat /> component in this library.

I think the best solution is to add a prop focusOnInputWhenOpeningKeyboard (with true value by default) to disable handleTextInputFocusWhenKeyboardShow and handleTextInputFocusWhenKeyboardHide calls.

@danilvalov
Copy link
Contributor

I added PR #2573 to fix it

@anauk
Copy link
Author

anauk commented Dec 23, 2024 via email

@anauk
Copy link
Author

anauk commented Dec 24, 2024 via email

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

No branches or pull requests

2 participants