File tree Expand file tree Collapse file tree
apps/meteor/client/views/room/MessageList/hooks Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @rocket.chat/meteor " : patch
3+ ---
4+
5+ Fixes the message list shifting when typing in the fully expanded message composer
Original file line number Diff line number Diff line change @@ -15,22 +15,35 @@ export const useKeepAtBottom = (isAtBottom: MutableRefObject<boolean | null>) =>
1515 const keepAtBottomRef = useSafeRefCallback (
1616 useCallback (
1717 ( node : HTMLDivElement ) => {
18+ const sendToBottom = ( ) => {
19+ if ( isAtBottom . current && handleRef . current ) {
20+ handleRef . current ( ) ;
21+ }
22+ } ;
1823 const listWrapper = node . firstChild ;
1924 const observer = new ResizeObserver ( ( ) => {
20- if ( isAtBottom . current ) {
21- if ( handleRef . current ) {
22- handleRef . current ( ) ;
23- }
24- }
25+ sendToBottom ( ) ;
2526 } ) ;
2627
2728 observer . observe ( node ) ;
2829 if ( listWrapper instanceof HTMLElement ) {
2930 observer . observe ( listWrapper ) ;
3031 }
3132
33+ const sendToBottomEvent = ( e : Event ) => {
34+ if ( ! ( e . target instanceof HTMLElement ) ) return ;
35+ if ( ! e . target . closest ( '.rc-message-box' ) ) return ;
36+ sendToBottom ( ) ;
37+ } ;
38+
39+ // Workaround for height hack in useAutoGrow
40+ // node.style.height = '0';
41+ // node.style.height = `${node.scrollHeight}px`;
42+ window . addEventListener ( 'input' , sendToBottomEvent ) ;
43+
3244 return ( ) => {
3345 observer . disconnect ( ) ;
46+ window . removeEventListener ( 'input' , sendToBottomEvent ) ;
3447 } ;
3548 } ,
3649 [ isAtBottom ] ,
You can’t perform that action at this time.
0 commit comments