@@ -34,7 +34,13 @@ export const AssignedEntities = ({
3434 return sortByString ( a . name , b . name , 'asc' ) ;
3535 } ) ;
3636
37- const items = sortedEntities ?. map ( ( entity : CombinedEntity ) => (
37+ // We don't need to send all items to the TruncatedList component for performance reasons,
38+ // since past a certain count they will be hidden within the row.
39+ const MAX_ITEMS_TO_RENDER = 15 ;
40+ const entitiesToRender = sortedEntities . slice ( 0 , MAX_ITEMS_TO_RENDER ) ;
41+ const totalCount = sortedEntities . length ;
42+
43+ const items = entitiesToRender ?. map ( ( entity : CombinedEntity ) => (
3844 < Box
3945 key = { entity . id }
4046 sx = { {
@@ -75,37 +81,42 @@ export const AssignedEntities = ({
7581 < Box >
7682 < TruncatedList
7783 addEllipsis
78- customOverflowButton = { ( numHiddenItems ) => (
79- < Box
80- sx = { {
81- alignItems : 'center' ,
82- backgroundColor :
83- theme . name === 'light'
84- ? theme . tokens . color . Ultramarine [ 20 ]
85- : theme . tokens . color . Neutrals . Black ,
86- borderRadius : 1 ,
87- display : 'flex' ,
88- height : '20px' ,
89- maxWidth : 'max-content' ,
90- padding : `${ theme . tokens . spacing . S4 } ${ theme . tokens . spacing . S8 } ` ,
91- position : 'relative' ,
92- top : 2 ,
93- } }
94- >
95- < Tooltip placement = "top" title = "Click to View All Entities" >
96- < Button
97- onClick = { ( ) => onButtonClick ( role . name as EntityRoleType ) }
98- sx = { {
99- color : theme . tokens . alias . Content . Text . Primary . Default ,
100- font : theme . tokens . alias . Typography . Label . Regular . Xs ,
101- padding : 0 ,
102- } }
103- >
104- +{ numHiddenItems }
105- </ Button >
106- </ Tooltip >
107- </ Box >
108- ) }
84+ customOverflowButton = { ( numHiddenByTruncate ) => {
85+ const numHiddenItems =
86+ totalCount - MAX_ITEMS_TO_RENDER + numHiddenByTruncate ;
87+
88+ return (
89+ < Box
90+ sx = { {
91+ alignItems : 'center' ,
92+ backgroundColor :
93+ theme . name === 'light'
94+ ? theme . tokens . color . Ultramarine [ 20 ]
95+ : theme . tokens . color . Neutrals . Black ,
96+ borderRadius : 1 ,
97+ display : 'flex' ,
98+ height : '20px' ,
99+ maxWidth : 'max-content' ,
100+ padding : `${ theme . tokens . spacing . S4 } ${ theme . tokens . spacing . S8 } ` ,
101+ position : 'relative' ,
102+ top : 2 ,
103+ } }
104+ >
105+ < Tooltip placement = "top" title = "Click to View All Entities" >
106+ < Button
107+ onClick = { ( ) => onButtonClick ( role . name as EntityRoleType ) }
108+ sx = { {
109+ color : theme . tokens . alias . Content . Text . Primary . Default ,
110+ font : theme . tokens . alias . Typography . Label . Regular . Xs ,
111+ padding : 0 ,
112+ } }
113+ >
114+ +{ numHiddenItems }
115+ </ Button >
116+ </ Tooltip >
117+ </ Box >
118+ ) ;
119+ } }
109120 justifyOverflowButtonRight
110121 listContainerSx = { {
111122 width : '100%' ,
0 commit comments