Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6427: Chips respect removable function #6428

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions components/lib/chips/Chips.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const Chips = React.memo(
}

let values = [...props.value];
const removedItem = values.splice(index, 1);
const removedItem = values.splice(index, 1)[0];

if (!isRemovable(removedItem, index)) {
return;
Expand Down Expand Up @@ -319,18 +319,18 @@ export const Chips = React.memo(
};

const createRemoveIcon = (value, index) => {
const iconProps = mergeProps(
{
className: cx('removeTokenIcon'),
onClick: (event) => removeItem(event, index),
'aria-hidden': 'true'
},
ptm('removeTokenIcon')
);
const icon = props.removeIcon || <TimesCircleIcon {...iconProps} />;
const removeIcon = IconUtils.getJSXIcon(icon, { ...iconProps }, { props });

if (!props.disabled && !props.readOnly && isRemovable(value, index)) {
const iconProps = mergeProps(
{
className: cx('removeTokenIcon'),
onClick: (event) => removeItem(event, index),
'aria-hidden': 'true'
},
ptm('removeTokenIcon')
);
const icon = props.removeIcon || <TimesCircleIcon {...iconProps} />;
const removeIcon = IconUtils.getJSXIcon(icon, { ...iconProps }, { props });

return removeIcon;
}

Expand Down
Loading