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

First message not visible when scrolling to the top after opening the keyboard. #2544

Open
joaquin-boto-celta opened this issue Oct 1, 2024 · 5 comments

Comments

@joaquin-boto-celta
Copy link

Issue Description

When I open the keyboard, the chat window shifts up correctly, and I'm able to see the input field without any issues. However, when I scroll all the way to the top of the chat, the first message does not appear. It seems to be cut off or not rendered at all.

Steps to Reproduce / Code Snippets

untitled.webm

image

image

image

Additional Information

  • Nodejs version: 20.11.1
  • React version: 18.2.0
  • React Native version: 0.72.4
  • react-native-gifted-chat version: "^2.6.2"
  • Platform(s) (iOS, Android, or both?): Android
  • TypeScript version: "^4.8.4"
@joaquin-boto-celta
Copy link
Author

I solved it by downgrading to version ^2.4.0

@fukemy
Copy link

fukemy commented Oct 3, 2024

many accepted pull request without check, do not using lasted version

@wallissonpr
Copy link

I solved it like this:

function Chat() {
  const [keyboardHeight, setKeyboardHeight] = useState(0);

  useEffect(() => {
    const keyboardDidShowListener = Keyboard.addListener(
      "keyboardDidShow",
      event => {
        setKeyboardHeight(event.endCoordinates.height);
      },
    );

    const keyboardDidHideListener = Keyboard.addListener(
      "keyboardDidHide",
      () => {
        setKeyboardHeight(0);
      },
    );

    return () => {
      keyboardDidShowListener.remove();
      keyboardDidHideListener.remove();
    };
  }, [params.id]);

  return (
    <Box flex={1}>
      <GiftedChat
        locale={"pt-br"}
        messages={chats.getByID[params.id]}
        onSend={messages => onSend(messages)}
        placeholder="Mensagem"
        scrollToBottom
        listViewProps={{
          contentContainerStyle: {
            flexGrow: 1,
            justifyContent: "flex-start",
            paddingBottom: keyboardHeight,
          },
        }}
        keyboardShouldPersistTaps="never"
        renderBubble={renderBubble}
        renderInputToolbar={renderInputToolbar}
        renderMessageText={renderMessageText}
        renderComposer={renderComposer}
        alwaysShowSend
        renderSend={renderSend}
        messagesContainerStyle={{backgroundColor: theme.colors.background}}
        user={{
          _id: user.driver_id,
          name: plate,
        }}
      />
    </Box>
  );
}

export default memo(Chat);

@tannguyen05
Copy link

same issue

@thuandohoang
Copy link

Same issue, this way fixes it.

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

5 participants