FaridSafi / react-native-gifted-chat

💬 The most complete chat UI for React Native
https://gifted.chat
MIT License
13.57k stars 3.55k forks source link

where the keyboard height remains on the screen after hiding the keyboard #2528

Open sathyapriya31 opened 2 months ago

sathyapriya31 commented 2 months ago

Screenshot_2024-09-04-13-07-52-76_c23f98e48ae5e53680995170d5870881

the keyboard remains visible or its height is retained when navigating away from the screen and then returning to it

[FILL THIS OUT]

Steps to Reproduce / Code Snippets

[FILL THIS OUT]

Expected Results

[FILL THIS OUT]

Additional Information

sahilrathi01 commented 2 months ago

same did you fixed this? Screenshot 2024-09-06 at 6 03 21 PM

kasp416h commented 2 months ago

Same here on android

fukemy commented 2 months ago

fast solution: catch onFocus screen event, before navigate/show modal -> hide keyboard first

sahilrathi01 commented 2 months ago

keyboard is not getting visiiable

https://github.com/user-attachments/assets/12baa07f-e050-486a-880e-0a6b3fb45181

mirsahib commented 2 months ago

fast solution: catch onFocus screen event, before navigate/show modal -> hide keyboard first

can you please post some sample code i have been trying with this with no luck

const navigation = useNavigation();

  useEffect(() => {
    const unsubscribe = navigation.addListener('beforeRemove', () => {
      // Hide the keyboard just before leaving the screen
      Keyboard.dismiss();
      console.log('Keyboard dismissed');
    });

    return unsubscribe;
  }, [navigation]);
fukemy commented 2 months ago

fast solution: catch onFocus screen event, before navigate/show modal -> hide keyboard first

can you please post some sample code i have been trying with this with no luck


const navigation = useNavigation();

  useEffect(() => {

    const unsubscribe = navigation.addListener('beforeRemove', () => {

      // Hide the keyboard just before leaving the screen

      Keyboard.dismiss();

      console.log('Keyboard dismissed');

    });

    return unsubscribe;

  }, [navigation]);

dont do like that, before you navigate to new screen or show modal, lets check keyboard state first, hide it if showing, and navigate/show modal after delay ~250-300

NiharR027 commented 2 months ago

+1 we are facing this issue as well

Lil-Azurite commented 1 month ago

this helped me (iOS)

if (Keyboard.isVisible()) {
  const onKeyboardDidHide = () => {
    Keyboard.removeAllListeners('keyboardDidHide');
    navigation.navigate('');
  };

  Keyboard.addListener('keyboardDidHide', onKeyboardDidHide);
  Keyboard.dismiss();
} else {
  navigation.navigate('');
}
JatinjeetSingh12 commented 1 month ago

any solution?

MGS-DEV commented 1 month ago

Same problem! Hiding the keyboard when exiting the screen doesn't help.

ngdbao commented 1 month ago

no solution until now UI does not move down when keyboard hiding (only happens if I press onSend). Since tapping out to dismiss keyboard, it works fine

i have 2 apps One with Giftedchat nested inside bottom tabbar, problem occurs One without bottom tabbar, works fine. But I'm not sure that's the reason

ngdbao commented 1 month ago

i Think problem from useAnimatedKeyboard, this value stop tracking keyboard height after press onSend

fukemy commented 1 month ago

Use rn keyboard controller instead

claudiozam commented 2 days ago

In react-native-gifted-chat v2.4.1 no problem.