@@ -62,12 +62,19 @@ const NoticeList: FC<NoticeListProps> = (props) => {
6262
6363 // Clean hover key
6464 useEffect ( ( ) => {
65- if ( hoverKeys . length > 1 ) {
65+ if ( stack && hoverKeys . length > 1 ) {
6666 setHoverKeys ( ( prev ) =>
6767 prev . filter ( ( key ) => keys . some ( ( { key : dataKey } ) => key === dataKey ) ) ,
6868 ) ;
6969 }
70- } , [ hoverKeys , keys ] ) ;
70+ } , [ hoverKeys , keys , stack ] ) ;
71+
72+ // Force update latest notice
73+ useEffect ( ( ) => {
74+ if ( stack && dictRef . current [ keys [ keys . length - 1 ] ?. key ] ) {
75+ setLatestNotice ( dictRef . current [ keys [ keys . length - 1 ] ?. key ] ) ;
76+ }
77+ } , [ keys , stack ] ) ;
7178
7279 return (
7380 < CSSMotionList
@@ -83,11 +90,6 @@ const NoticeList: FC<NoticeListProps> = (props) => {
8390 onAllRemoved = { ( ) => {
8491 onAllNoticeRemoved ( placement ) ;
8592 } }
86- onAppearPrepare = { ( element ) => {
87- if ( element . parentNode . lastElementChild === element ) {
88- setLatestNotice ( element as HTMLDivElement ) ;
89- }
90- } }
9193 >
9294 { (
9395 { config, className : motionClassName , style : motionStyle , index : motionIndex } ,
@@ -99,10 +101,10 @@ const NoticeList: FC<NoticeListProps> = (props) => {
99101
100102 // If dataIndex is -1, that means this notice has been removed in data, but still in dom
101103 // Should minus (motionIndex - 1) to get the correct index because keys.length is not the same as dom length
102- const index = keys . length - 1 - ( dataIndex > - 1 ? dataIndex : motionIndex - 1 ) ;
103- const transformX = placement === 'top' || placement === 'bottom' ? '-50%' : '0' ;
104104 const stackStyle : CSSProperties = { } ;
105105 if ( stack ) {
106+ const index = keys . length - 1 - ( dataIndex > - 1 ? dataIndex : motionIndex - 1 ) ;
107+ const transformX = placement === 'top' || placement === 'bottom' ? '-50%' : '0' ;
106108 if ( index > 0 ) {
107109 stackStyle . height = expanded
108110 ? dictRef . current [ key ] ?. offsetHeight
@@ -156,7 +158,7 @@ const NoticeList: FC<NoticeListProps> = (props) => {
156158 key = { key }
157159 eventKey = { key }
158160 onNoticeClose = { onNoticeClose }
159- hovering = { hoverKeys . length > 0 }
161+ hovering = { stack && hoverKeys . length > 0 }
160162 />
161163 </ div >
162164 ) ;
0 commit comments