@@ -155,6 +155,13 @@ function Overflow<ItemType = any>(
155
155
const len = mergedData . length ;
156
156
const lastIndex = len - 1 ;
157
157
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
+
158
165
for ( let i = 0 ; i < len ; i += 1 ) {
159
166
const currentItemWidth = getItemWidth ( i ) ;
160
167
@@ -179,7 +186,7 @@ function Overflow<ItemType = any>(
179
186
// Can not hold all the content to show rest
180
187
updateDisplayCount ( i - 1 ) ;
181
188
setSuffixFixedStart (
182
- totalWidth - currentItemWidth - suffixWidth + mergedRestWidth ,
189
+ totalWidth - currentItemWidth - suffixWidth + restWidth ,
183
190
) ;
184
191
break ;
185
192
} else if ( i === lastIndex ) {
@@ -194,14 +201,7 @@ function Overflow<ItemType = any>(
194
201
setSuffixFixedStart ( null ) ;
195
202
}
196
203
}
197
- } , [
198
- containerWidth ,
199
- itemWidths ,
200
- mergedRestWidth ,
201
- suffixWidth ,
202
- getKey ,
203
- mergedData ,
204
- ] ) ;
204
+ } , [ containerWidth , itemWidths , restWidth , suffixWidth , getKey , mergedData ] ) ;
205
205
206
206
// ================================ Render ================================
207
207
const displayRest = restReady && ! ! omittedItems . length ;
@@ -238,7 +238,8 @@ function Overflow<ItemType = any>(
238
238
{ /* Rest Count Item */ }
239
239
{ showRest ? (
240
240
< Item
241
- order = { displayRest ? displayCount : mergedData . length }
241
+ // When not show, order should be the last
242
+ order = { displayRest ? displayCount : Number . MAX_SAFE_INTEGER }
242
243
prefixCls = { itemPrefixCls }
243
244
className = { `${ itemPrefixCls } -rest` }
244
245
responsive = { isResponsive }
0 commit comments