File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { useDispatch , useSelector } from 'react-redux' ;
2- import { useEffect } from 'react' ;
2+ import { useEffect , useRef } from 'react' ;
33import { Nav , ButtonGroup , Dropdown } from 'react-bootstrap' ;
44import { useTranslation } from 'react-i18next' ;
55import filterWords from 'leo-profanity' ;
@@ -41,6 +41,14 @@ const Channels = () => {
4141 dispatch ( setCurrentChannel ( channel ) ) ;
4242 } ;
4343
44+ const channelsEndRef = useRef ( null ) ;
45+
46+ useEffect ( ( ) => {
47+ if ( channelsEndRef . current ) {
48+ channelsEndRef . current . scrollIntoView ( { behavior : 'auto' } ) ;
49+ }
50+ } , [ channels , currentChannel ] ) ;
51+
4452 return (
4553 < Nav className = "flex-column nav-fill px-2 mb-3 overflow-auto h-100 d-block" >
4654 { channels . map ( ( channel ) => (
@@ -92,6 +100,7 @@ const Channels = () => {
92100 ) }
93101 </ li >
94102 ) ) }
103+ < div ref = { channelsEndRef } />
95104 </ Nav >
96105 ) ;
97106} ;
You can’t perform that action at this time.
0 commit comments