@@ -55,6 +55,7 @@ function Overflow<ItemType = any>(
5555 const [ restWidth , setRestWidth ] = createUseState ( 0 ) ;
5656
5757 const [ suffixWidth , setSuffixWidth ] = createUseState ( 0 ) ;
58+ const [ suffixFixedStart , setSuffixFixedStart ] = useState < number > ( null ) ;
5859
5960 const [ displayCount , setDisplayCount ] = useState ( 0 ) ;
6061 const [ restReady , setRestReady ] = useState ( false ) ;
@@ -171,17 +172,26 @@ function Overflow<ItemType = any>(
171172 ) {
172173 // Additional check if match the end
173174 updateDisplayCount ( lastIndex ) ;
175+ setSuffixFixedStart ( null ) ;
174176 break ;
175177 } else if ( totalWidth + mergedRestWidth > containerWidth ) {
176178 // Can not hold all the content to show rest
177179 updateDisplayCount ( i - 1 ) ;
180+ setSuffixFixedStart (
181+ totalWidth - currentItemWidth - suffixWidth + mergedRestWidth ,
182+ ) ;
178183 break ;
179184 } else if ( i === lastIndex ) {
180185 // Reach the end
181186 updateDisplayCount ( lastIndex ) ;
187+ setSuffixFixedStart ( totalWidth - suffixWidth ) ;
182188 break ;
183189 }
184190 }
191+
192+ if ( suffix && getItemWidth ( 0 ) + suffixWidth > containerWidth ) {
193+ setSuffixFixedStart ( null ) ;
194+ }
185195 }
186196 } , [
187197 containerWidth ,
@@ -195,6 +205,15 @@ function Overflow<ItemType = any>(
195205 // ================================ Render ================================
196206 const displayRest = restReady && ! ! omittedItems . length ;
197207
208+ let suffixStyle : React . CSSProperties = { } ;
209+ if ( suffixFixedStart !== null ) {
210+ suffixStyle = {
211+ position : 'absolute' ,
212+ left : suffixFixedStart ,
213+ top : 0 ,
214+ } ;
215+ }
216+
198217 let overflowNode = (
199218 < div className = { classNames ( prefixCls , className ) } style = { style } ref = { ref } >
200219 { mergedData . map ( ( item , index ) => {
@@ -240,6 +259,7 @@ function Overflow<ItemType = any>(
240259 responsive = { isResponsive }
241260 registerSize = { registerSuffixSize }
242261 display
262+ style = { suffixStyle }
243263 >
244264 { suffix }
245265 </ Item >
0 commit comments