Skip to content

Commit

Permalink
chatmenu scrolls down again
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Feb 4, 2024
1 parent 08adceb commit 72f2f93
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/src/menu/game/gameScreenContent/ChatMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export default class ChatMenu extends React.Component<ChatMenuProps, ChatMenuSta
ChatMenu.instance = null;
}
render(){
console.log("chat rerender");

return <div className="chat-menu chat-menu-colors">
<ContentTab close={false}>{translate("menu.chat.title")}</ContentTab>
<ChatMessageSection filter={this.state.filter} />
Expand Down Expand Up @@ -110,6 +108,12 @@ function ChatMessageSection(props: { filter: RegExp | null }): ReactElement {
return () => GAME_MANAGER.removeStateListener(stateListener);
}, [props.filter, setMessages]);

//scroll chat to bottom when filter is shut off or loaded
useEffect(() => {
if (self.current === null) return;
self.current.scrollTop = self.current.scrollHeight;
}, [props.filter])

return <div className="message-section" ref={self}>
<div className="message-list">
{filteredMessages.map((msg, index) => {
Expand Down

0 comments on commit 72f2f93

Please sign in to comment.