Skip to content

Commit

Permalink
fix: hide remove button from chip when readOnly and only one chip
Browse files Browse the repository at this point in the history
  • Loading branch information
HellWolf93 committed Jun 26, 2020
1 parent 6285055 commit e3c7acc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/MultiSelect/chips.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function Chips(props) {
if (Array.isArray(value)) {
return value.map(val => {
const onDeleteCallback = disabled || readOnly ? null : () => onDelete(val);

return (
<StyledChip
key={val.name}
Expand All @@ -22,7 +21,8 @@ function Chips(props) {
);
});
}
return <StyledChip label={value.label} variant={variant} onDelete={() => onDelete(value)} />;
const onDeleteCallback = disabled || readOnly ? null : () => onDelete(value);
return <StyledChip label={value.label} variant={variant} onDelete={onDeleteCallback} />;
}

Chips.propTypes = {
Expand Down

0 comments on commit e3c7acc

Please sign in to comment.