fix: collapse selected host chips to count badge when >2 selected

renderTags now shows individual chips for 1-2 selections, and a single
'N hosts' chip (with clear-all × button) for 3+. Prevents the input
from growing vertically when many hosts are selected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
fuomag9
2026-02-27 12:13:08 +01:00
parent 50028581b0
commit 1028322645

View File

@@ -375,17 +375,28 @@ export default function AnalyticsClient() {
<ListItemText primary={option} primaryTypographyProps={{ variant: 'body2', noWrap: true }} />
</li>
)}
renderTags={(value, getTagProps) =>
value.map((option, index) => (
renderTags={(value, getTagProps) => {
if (value.length <= 2) {
return value.map((option, index) => (
<Chip
{...getTagProps({ index })}
key={option}
label={option}
size="small"
sx={{ maxWidth: 140 }}
/>
));
}
// Collapse to a single count chip so the input never grows tall
return [
<Chip
{...getTagProps({ index })}
key={option}
label={option}
key="count"
label={`${value.length} hosts`}
size="small"
sx={{ maxWidth: 120 }}
/>
))
}
onDelete={() => setSelectedHosts([])}
/>,
];
}}
renderInput={(params) => (
<TextField
{...params}