Skip to content

Commit

Permalink
[@mantine/core] Fix Pill to respect disabled state (mantinedev#5959)
Browse files Browse the repository at this point in the history
  • Loading branch information
snturk committed Mar 24, 2024
1 parent e3e3bb8 commit 2685bae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/@mantine/core/src/components/Pill/Pill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export const Pill = factory<PillFactory>((_props, ref) => {
tabIndex={-1}
aria-hidden
unstyled={unstyled}
disabled={disabled}
{...removeButtonProps}
{...getStyles('remove', {
className: removeButtonProps?.className,
Expand All @@ -139,6 +140,10 @@ export const Pill = factory<PillFactory>((_props, ref) => {
removeButtonProps?.onMouseDown?.(event);
}}
onClick={(event) => {
if (disabled) {
event.preventDefault();
return;
}
event.stopPropagation();
onRemove?.();
removeButtonProps?.onClick?.(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ export const TagsInput = factory<TagsInputFactory>((_props, ref) => {
<Pill
key={`${item}-${index}`}
withRemoveButton={!readOnly}
disabled={disabled}
onRemove={() => {
setValue(_value.filter((i) => item !== i));
onRemove?.(item);
Expand Down

0 comments on commit 2685bae

Please sign in to comment.