@@ -155,6 +155,13 @@ function Overflow<ItemType = any>(
155155 const len = mergedData . length ;
156156 const lastIndex = len - 1 ;
157157
158+ // When data count change to 0, reset this since not loop will reach
159+ if ( ! len ) {
160+ updateDisplayCount ( 0 ) ;
161+ setSuffixFixedStart ( null ) ;
162+ return ;
163+ }
164+
158165 for ( let i = 0 ; i < len ; i += 1 ) {
159166 const currentItemWidth = getItemWidth ( i ) ;
160167
@@ -179,7 +186,7 @@ function Overflow<ItemType = any>(
179186 // Can not hold all the content to show rest
180187 updateDisplayCount ( i - 1 ) ;
181188 setSuffixFixedStart (
182- totalWidth - currentItemWidth - suffixWidth + mergedRestWidth ,
189+ totalWidth - currentItemWidth - suffixWidth + restWidth ,
183190 ) ;
184191 break ;
185192 } else if ( i === lastIndex ) {
@@ -194,14 +201,7 @@ function Overflow<ItemType = any>(
194201 setSuffixFixedStart ( null ) ;
195202 }
196203 }
197- } , [
198- containerWidth ,
199- itemWidths ,
200- mergedRestWidth ,
201- suffixWidth ,
202- getKey ,
203- mergedData ,
204- ] ) ;
204+ } , [ containerWidth , itemWidths , restWidth , suffixWidth , getKey , mergedData ] ) ;
205205
206206 // ================================ Render ================================
207207 const displayRest = restReady && ! ! omittedItems . length ;
@@ -238,7 +238,8 @@ function Overflow<ItemType = any>(
238238 { /* Rest Count Item */ }
239239 { showRest ? (
240240 < Item
241- order = { displayRest ? displayCount : mergedData . length }
241+ // When not show, order should be the last
242+ order = { displayRest ? displayCount : Number . MAX_SAFE_INTEGER }
242243 prefixCls = { itemPrefixCls }
243244 className = { `${ itemPrefixCls } -rest` }
244245 responsive = { isResponsive }
0 commit comments