File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,20 @@ const ChatHeader = ({
105
105
106
106
const closeThread = useMessageStore ( ( state ) => state . closeThread ) ;
107
107
108
+ const handleCloseThread = useCallback ( ( ) => {
109
+ const threadMessageId = threadMainMessage ?. _id ;
110
+ closeThread ( ) ;
111
+ setTimeout ( ( ) => {
112
+ const element = document . getElementById ( `ec-message-body-${ threadMessageId } ` ) ;
113
+ if ( element ) {
114
+ element . scrollIntoView ( {
115
+ behavior : 'instant' ,
116
+ block : 'start' ,
117
+ } ) ;
118
+ }
119
+ } , 300 ) ;
120
+ } , [ closeThread , threadMainMessage ] ) ;
121
+
108
122
const setShowMembers = useMemberStore ( ( state ) => state . setShowMembers ) ;
109
123
const setShowSearch = useSearchMessageStore ( ( state ) => state . setShowSearch ) ;
110
124
const setShowPinned = usePinnedMessageStore ( ( state ) => state . setShowPinned ) ;
@@ -430,7 +444,7 @@ const ChatHeader = ({
430
444
{ isThreadOpen && (
431
445
< DynamicHeader
432
446
title = { threadMainMessage }
433
- handleClose = { closeThread }
447
+ handleClose = { handleCloseThread }
434
448
iconName = "arrow-back"
435
449
/>
436
450
) }
You can’t perform that action at this time.
0 commit comments