@@ -90,6 +90,8 @@ function Overflow<ItemType = any>(
90
90
91
91
const createUseState = useBatchFrameState ( ) ;
92
92
93
+ const fullySSR = ssr === 'full'
94
+
93
95
const [ containerWidth , setContainerWidth ] = createUseState < number > ( null ) ;
94
96
const mergedContainerWidth = containerWidth || 0 ;
95
97
@@ -103,7 +105,15 @@ function Overflow<ItemType = any>(
103
105
const [ suffixWidth , setSuffixWidth ] = createUseState ( 0 ) ;
104
106
const [ suffixFixedStart , setSuffixFixedStart ] = useState < number > ( null ) ;
105
107
106
- const [ displayCount , setDisplayCount ] = useState ( 0 ) ;
108
+ const [ displayCount , setDisplayCount ] = useState ( null ) ;
109
+ const mergedDisplayCount = React . useMemo ( ( ) => {
110
+ if ( displayCount === null && fullySSR ) {
111
+ return Number . MAX_SAFE_INTEGER ;
112
+ }
113
+
114
+ return displayCount || 0 ;
115
+ } , [ displayCount , containerWidth ] ) ;
116
+
107
117
const [ restReady , setRestReady ] = useState ( false ) ;
108
118
109
119
const itemPrefixCls = `${ prefixCls } -item` ;
@@ -125,7 +135,7 @@ function Overflow<ItemType = any>(
125
135
let items = data ;
126
136
127
137
if ( isResponsive ) {
128
- if ( containerWidth === null && ssr === 'full' ) {
138
+ if ( containerWidth === null && fullySSR ) {
129
139
items = data ;
130
140
} else {
131
141
items = data . slice (
@@ -142,10 +152,10 @@ function Overflow<ItemType = any>(
142
152
143
153
const omittedItems = useMemo ( ( ) => {
144
154
if ( isResponsive ) {
145
- return data . slice ( displayCount + 1 ) ;
155
+ return data . slice ( mergedDisplayCount + 1 ) ;
146
156
}
147
157
return data . slice ( mergedData . length ) ;
148
- } , [ data , mergedData , isResponsive , displayCount ] ) ;
158
+ } , [ data , mergedData , isResponsive , mergedDisplayCount ] ) ;
149
159
150
160
// ================================= Item =================================
151
161
const getKey = useCallback (
@@ -299,7 +309,7 @@ function Overflow<ItemType = any>(
299
309
item,
300
310
itemKey : key ,
301
311
registerSize,
302
- display : index <= displayCount ,
312
+ display : index <= mergedDisplayCount ,
303
313
} }
304
314
>
305
315
{ renderRawItem ( item , index ) }
@@ -318,15 +328,15 @@ function Overflow<ItemType = any>(
318
328
renderItem = { mergedRenderItem }
319
329
itemKey = { key }
320
330
registerSize = { registerSize }
321
- display = { index <= displayCount }
331
+ display = { index <= mergedDisplayCount }
322
332
/>
323
333
) ;
324
334
} ;
325
335
326
336
// >>>>> Rest node
327
337
let restNode : React . ReactNode ;
328
338
const restContextProps = {
329
- order : displayRest ? displayCount : Number . MAX_SAFE_INTEGER ,
339
+ order : displayRest ? mergedDisplayCount : Number . MAX_SAFE_INTEGER ,
330
340
className : `${ itemPrefixCls } -rest` ,
331
341
registerSize : registerOverflowSize ,
332
342
display : displayRest ,
@@ -375,7 +385,7 @@ function Overflow<ItemType = any>(
375
385
{ suffix && (
376
386
< Item
377
387
{ ...itemSharedProps }
378
- order = { displayCount }
388
+ order = { mergedDisplayCount }
379
389
className = { `${ itemPrefixCls } -suffix` }
380
390
registerSize = { registerSuffixSize }
381
391
display
0 commit comments