@@ -176,11 +176,19 @@ function Overflow<ItemType = any>(
176
176
[ renderItem ] ,
177
177
) ;
178
178
179
- function updateDisplayCount ( count : number , notReady ?: boolean ) {
179
+ function updateDisplayCount (
180
+ count : number ,
181
+ suffixFixedStartVal : number ,
182
+ notReady ?: boolean ,
183
+ ) {
180
184
// React 18 will sync render even when the value is same in some case.
181
185
// We take `mergedData` as deps which may cause dead loop if it's dynamic generate.
182
186
// ref: https://github.com/ant-design/ant-design/issues/36559
183
- if ( displayCount === count ) {
187
+ if (
188
+ displayCount === count &&
189
+ ( suffixFixedStartVal === undefined ||
190
+ suffixFixedStartVal === suffixFixedStart )
191
+ ) {
184
192
return ;
185
193
}
186
194
@@ -190,6 +198,10 @@ function Overflow<ItemType = any>(
190
198
191
199
onVisibleChange ?.( count ) ;
192
200
}
201
+
202
+ if ( suffixFixedStartVal !== undefined ) {
203
+ setSuffixFixedStart ( suffixFixedStartVal ) ;
204
+ }
193
205
}
194
206
195
207
// ================================= Size =================================
@@ -233,8 +245,7 @@ function Overflow<ItemType = any>(
233
245
234
246
// When data count change to 0, reset this since not loop will reach
235
247
if ( ! len ) {
236
- updateDisplayCount ( 0 ) ;
237
- setSuffixFixedStart ( null ) ;
248
+ updateDisplayCount ( 0 , null ) ;
238
249
return ;
239
250
}
240
251
@@ -248,7 +259,7 @@ function Overflow<ItemType = any>(
248
259
249
260
// Break since data not ready
250
261
if ( currentItemWidth === undefined ) {
251
- updateDisplayCount ( i - 1 , true ) ;
262
+ updateDisplayCount ( i - 1 , undefined , true ) ;
252
263
break ;
253
264
}
254
265
@@ -263,13 +274,12 @@ function Overflow<ItemType = any>(
263
274
totalWidth + getItemWidth ( lastIndex ) ! <= mergedContainerWidth )
264
275
) {
265
276
// Additional check if match the end
266
- updateDisplayCount ( lastIndex ) ;
267
- setSuffixFixedStart ( null ) ;
277
+ updateDisplayCount ( lastIndex , null ) ;
268
278
break ;
269
279
} else if ( totalWidth + mergedRestWidth > mergedContainerWidth ) {
270
280
// Can not hold all the content to show rest
271
- updateDisplayCount ( i - 1 ) ;
272
- setSuffixFixedStart (
281
+ updateDisplayCount (
282
+ i - 1 ,
273
283
totalWidth - currentItemWidth - suffixWidth + restWidth ,
274
284
) ;
275
285
break ;
0 commit comments