@@ -55,6 +55,7 @@ function Overflow<ItemType = any>(
55
55
const [ restWidth , setRestWidth ] = createUseState ( 0 ) ;
56
56
57
57
const [ suffixWidth , setSuffixWidth ] = createUseState ( 0 ) ;
58
+ const [ suffixFixedStart , setSuffixFixedStart ] = useState < number > ( null ) ;
58
59
59
60
const [ displayCount , setDisplayCount ] = useState ( 0 ) ;
60
61
const [ restReady , setRestReady ] = useState ( false ) ;
@@ -171,17 +172,26 @@ function Overflow<ItemType = any>(
171
172
) {
172
173
// Additional check if match the end
173
174
updateDisplayCount ( lastIndex ) ;
175
+ setSuffixFixedStart ( null ) ;
174
176
break ;
175
177
} else if ( totalWidth + mergedRestWidth > containerWidth ) {
176
178
// Can not hold all the content to show rest
177
179
updateDisplayCount ( i - 1 ) ;
180
+ setSuffixFixedStart (
181
+ totalWidth - currentItemWidth - suffixWidth + mergedRestWidth ,
182
+ ) ;
178
183
break ;
179
184
} else if ( i === lastIndex ) {
180
185
// Reach the end
181
186
updateDisplayCount ( lastIndex ) ;
187
+ setSuffixFixedStart ( totalWidth - suffixWidth ) ;
182
188
break ;
183
189
}
184
190
}
191
+
192
+ if ( suffix && getItemWidth ( 0 ) + suffixWidth > containerWidth ) {
193
+ setSuffixFixedStart ( null ) ;
194
+ }
185
195
}
186
196
} , [
187
197
containerWidth ,
@@ -195,6 +205,15 @@ function Overflow<ItemType = any>(
195
205
// ================================ Render ================================
196
206
const displayRest = restReady && ! ! omittedItems . length ;
197
207
208
+ let suffixStyle : React . CSSProperties = { } ;
209
+ if ( suffixFixedStart !== null ) {
210
+ suffixStyle = {
211
+ position : 'absolute' ,
212
+ left : suffixFixedStart ,
213
+ top : 0 ,
214
+ } ;
215
+ }
216
+
198
217
let overflowNode = (
199
218
< div className = { classNames ( prefixCls , className ) } style = { style } ref = { ref } >
200
219
{ mergedData . map ( ( item , index ) => {
@@ -240,6 +259,7 @@ function Overflow<ItemType = any>(
240
259
responsive = { isResponsive }
241
260
registerSize = { registerSuffixSize }
242
261
display
262
+ style = { suffixStyle }
243
263
>
244
264
{ suffix }
245
265
</ Item >
0 commit comments