1- import React , { Key } from 'react'
1+ import React , { Dispatch , Key , SetStateAction } from 'react'
22import classNames from 'classnames'
33import './ChatList.css'
44
55import ChatItem from '../ChatItem/ChatItem'
66import { IChatListProps , ChatListEvent } from '../type'
77
8+ let list : Dispatch < SetStateAction < any > > [ ] = [ ]
9+
810const ChatList : React . FC < IChatListProps > = props => {
911 const onClick : ChatListEvent = ( item , index , event ) => {
1012 if ( props . onClick instanceof Function ) props . onClick ( item , index , event )
@@ -19,6 +21,15 @@ const ChatList: React.FC<IChatListProps> = props => {
1921 if ( props . onAvatarError instanceof Function ) props . onAvatarError ( item , index , event )
2022 }
2123
24+ const setDragStates = < S , > ( state : Dispatch < SetStateAction < S > > ) => {
25+ list . push ( state )
26+ }
27+
28+ const onDragLeaveMW = ( e : React . MouseEvent < HTMLElement > , id : Number | string ) => {
29+ if ( list . length > 0 ) list . forEach ( item => item ( false ) )
30+ props . onDragLeave ( e , id )
31+ }
32+
2233 return (
2334 < div className = { classNames ( 'rce-container-clist' , props . className ) } >
2435 { props . dataSource . map ( ( x , i : number ) => (
@@ -34,8 +45,9 @@ const ChatList: React.FC<IChatListProps> = props => {
3445 onDragOver = { props ?. onDragOver }
3546 onDragEnter = { props ?. onDragEnter }
3647 onDrop = { props . onDrop }
37- onDragLeave = { props . onDragLeave }
48+ onDragLeave = { onDragLeaveMW }
3849 onDragComponent = { props . onDragComponent }
50+ setDragStates = { setDragStates }
3951 />
4052 ) ) }
4153 </ div >
0 commit comments