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

Unable to scroll to the top of the chat when the keyboard is open, and it doesn’t automatically scroll to the bottom when a new message is sent. #2527

Open
nishmitha03 opened this issue Sep 3, 2024 · 3 comments

Comments

@nishmitha03
Copy link

nishmitha03 commented Sep 3, 2024

Issue Description

  1. Unable to scroll to the top of the chat when the keyboard is open.
  2. The chat doesn’t automatically scroll to the bottom when a new message is sent

Steps to Reproduce / Code Snippets

  1. Type a message in the chat.
  2. Open the keyboard.
  3. Attempt to scroll to the top of the chat.

Below is my code

import React, {useCallback, useEffect, useState} from 'react';
import {SafeAreaView} from 'react-native';
import {GiftedChat} from 'react-native-gifted-chat';

const ChatComponent = () => {
  const [messages, setMessages] = useState([]);

  useEffect(() => {
    setMessages([
      {
        _id: 1,
        text: 'Hello developer',
        createdAt: new Date(),
        user: {
          _id: 2,
          name: 'React Native',
          avatar: 'https://placeimg.com/140/140/any',
        },
      },
    ]);
  }, []);

  const onSend = useCallback((messages = []) => {
    setMessages(previousMessages =>
      GiftedChat.append(previousMessages, messages),
    );
  }, []);

  return (
    <SafeAreaView style={{flex: 1}}>
      <GiftedChat
        messages={messages}
        onSend={messages => onSend(messages)}
        user={{
          _id: 1,
        }}
      />
    </SafeAreaView>
  );
};

export default ChatComponent;
import React from 'react';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import ChatComponent from './ChatComponent';

const App = () => {
  return (
    <SafeAreaProvider>
      <ChatComponent />
    </SafeAreaProvider>
  );
};

export default App;

Expected Results

  1. The chat should remain scrollable to the top even when the keyboard is open.
  2. The chat should automatically scroll to the bottom when a new message is sent.

Additional Information

  • Nodejs version: v18.16.0
  • React version: 18.2.0
  • React Native version: 0.72.0
  • react-native-gifted-chat version: 2.6.1
  • Platform(s) (iOS, Android, or both?): IOS

Recording for -> Unable to scroll to the top of the chat when the keyboard is open.

Screen.Recording.2024-09-03.at.9.07.07.PM.mov

Recording for -> The chat doesn’t automatically scroll to the bottom when a new message is sent.

Screen.Recording.2024-09-03.at.9.08.09.PM.mov
@nishmitha03 nishmitha03 changed the title unable to scroll to the top of the chat when the keyboard is open. Unable to scroll to the top of the chat when the keyboard is open, and also it doesn’t automatically scroll to the bottom when a new message is sent. Sep 3, 2024
@nishmitha03 nishmitha03 changed the title Unable to scroll to the top of the chat when the keyboard is open, and also it doesn’t automatically scroll to the bottom when a new message is sent. Unable to scroll to the top of the chat when the keyboard is open, and it doesn’t automatically scroll to the bottom when a new message is sent. Sep 3, 2024
@nikita10001
Copy link

having the same issue

1 similar comment
@MrNapcae
Copy link

MrNapcae commented Sep 8, 2024

having the same issue

@osikes
Copy link

osikes commented Oct 25, 2024

same

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

4 participants