Skip to content

Commit ed899ca

Browse files
authored
Ensure MultiChoice does not overflow in height (#707)
1 parent dc98284 commit ed899ca

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

src/panel_material_ui/widgets/Select.jsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export function render({model, el, view}) {
197197
}
198198
if (multi && chip) {
199199
return (
200-
<Box sx={{display: "flex", flexWrap: "wrap", gap: 0.5}}>
200+
<Box sx={{display: "flex", flexWrap: "wrap", gap: 0.5, alignContent: "flex-start"}}>
201201
{selected.map((selected_value) => (
202202
<Chip
203203
color={color}
@@ -475,10 +475,26 @@ export function render({model, el, view}) {
475475

476476
const anchorEl = React.useRef(null)
477477

478+
const multiChipSx = React.useMemo(() => {
479+
if (!multi || !chip) { return selectSx }
480+
return [
481+
...Array.isArray(selectSx) ? selectSx : [selectSx],
482+
{
483+
height: "100%",
484+
"& .MuiSelect-select": {overflow: "hidden auto !important", height: "100% !important", boxSizing: "border-box", alignItems: "flex-start"},
485+
},
486+
]
487+
}, [selectSx, multi, chip])
488+
478489
return (
479-
<FormControl disabled={disabled} error={error_state} fullWidth variant={variant}>
490+
<FormControl disabled={disabled} error={error_state} fullWidth variant={variant} sx={multi && chip ? {height: "100%"} : undefined}>
480491
{label &&
481-
<InputLabel color={color} id={`select-label-${model.id}`} shrink={hasValue || open}>
492+
<InputLabel
493+
color={color}
494+
id={`select-label-${model.id}`}
495+
shrink={hasValue || open}
496+
sx={multi && chip && variant === "outlined" ? {backgroundColor: "background.paper", px: 0.5, zIndex: 1} : undefined}
497+
>
482498
{render_icon_text(label)}
483499
{model.description ? render_description({model, el, view}) : null}
484500
</InputLabel>
@@ -503,7 +519,7 @@ export function render({model, el, view}) {
503519
ref={anchorEl}
504520
renderValue={renderValue}
505521
size={size}
506-
sx={selectSx}
522+
sx={multiChipSx}
507523
value={value}
508524
variant={variant}
509525

0 commit comments

Comments
 (0)