@@ -171,9 +171,29 @@ const FilterCheckbox: FC<FilterCheckboxProps> = ({
171171 const iconWidth = 10 ;
172172 const iconWidthUnselected = 8 ;
173173 const overlapDistance = 6 ;
174- const containerWidth = iconWidth + ( options . length - 1 ) * overlapDistance + 1 ;
175174
176- const selectedStatuses = selectedValues || [ ] ;
175+ // 按颜色分组选项,并检查每种颜色是否有选中的选项
176+ const colorGroups : { color : string ; hasSelected : boolean } [ ] = [ ] ;
177+ const colorMap = new Map < string , { color : string ; hasSelected : boolean } > ( ) ;
178+
179+ options . forEach ( option => {
180+ if ( option . color ) {
181+ const isSelected = selectedValues . includes ( option . value ) ;
182+ const existing = colorMap . get ( option . color ) ;
183+ if ( existing ) {
184+ // 如果已有该颜色,更新选中状态(只要有一个选中即为选中)
185+ if ( isSelected ) {
186+ existing . hasSelected = true ;
187+ }
188+ } else {
189+ const group = { color : option . color , hasSelected : isSelected } ;
190+ colorMap . set ( option . color , group ) ;
191+ colorGroups . push ( group ) ;
192+ }
193+ }
194+ } ) ;
195+
196+ const containerWidth = iconWidth + ( colorGroups . length - 1 ) * overlapDistance + 1 ;
177197
178198 return (
179199 < div
@@ -185,27 +205,27 @@ const FilterCheckbox: FC<FilterCheckboxProps> = ({
185205 alignItems : 'center' ,
186206 } }
187207 >
188- { options . map ( ( item , index ) => {
189- const isSelected = selectedStatuses . includes ( item . value ) && item . color ;
208+ { colorGroups . map ( ( group , index ) => {
209+ const isSelected = group . hasSelected ;
190210 const baseSize = isSelected ? iconWidth : iconWidthUnselected ;
191211
192212 return isSelected ? (
193213 < div
194- key = { item . value }
214+ key = { group . color }
195215 style = { {
196216 position : 'absolute' ,
197217 left : index * overlapDistance ,
198218 width : baseSize ,
199219 height : baseSize ,
200220 borderRadius : '50%' ,
201221 zIndex : index ,
202- backgroundColor : item . color ,
222+ backgroundColor : group . color ,
203223 border : `1px solid ${ token . white } ` ,
204224 } }
205225 />
206226 ) : (
207227 < div
208- key = { item . value }
228+ key = { group . color }
209229 style = { {
210230 position : 'absolute' ,
211231 left : index * overlapDistance ,
0 commit comments