Skip to content

Commit

Permalink
[@mantine/core] Fix incorrect disabled prop handling in TagsInput a…
Browse files Browse the repository at this point in the history
…nd MultiSelect (#5959)
  • Loading branch information
rtivital committed Mar 26, 2024
1 parent 211b00c commit dc5ed3d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export const MultiSelect = factory<MultiSelectFactory>((_props, ref) => {
onRemove?.(item);
}}
unstyled={unstyled}
disabled={disabled}
{...getStyles('pill')}
>
{optionsLockup[item]?.label || item}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ export function Usage() {
);
}

export function Disabled() {
return (
<div style={{ padding: 40 }}>
<MultiSelect
disabled
label="disabled"
defaultValue={['React', 'Angular']}
placeholder="Enter tags"
/>
<fieldset disabled>
<MultiSelect
label="disabled fieldset"
defaultValue={['React', 'Angular']}
placeholder="Enter tags"
/>
</fieldset>
</div>
);
}

export function EmptyStringValue() {
return (
<div style={{ padding: 40 }}>
Expand Down
3 changes: 2 additions & 1 deletion packages/@mantine/core/src/components/Pill/Pill.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
color: var(--mantine-color-black);
}

&:where([data-with-remove]) {
&:where([data-with-remove]:not(:has(button:disabled))) {
padding-inline-end: 0;
}

Expand Down Expand Up @@ -87,6 +87,7 @@

.root[data-disabled] > &,
&:disabled {
display: none;
background-color: transparent;
width: 0.8em;
min-width: 0.8em;
Expand Down
5 changes: 4 additions & 1 deletion packages/@mantine/core/src/components/Pill/Pill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ export const Pill = factory<PillFactory>((_props, ref) => {
variant={_variant}
size={_size}
{...getStyles('root', { variant: _variant })}
mod={[{ 'with-remove': withRemoveButton, disabled: disabled || ctx?.disabled }, mod]}
mod={[
{ 'with-remove': withRemoveButton && !disabled, disabled: disabled || ctx?.disabled },
mod,
]}
{...others}
>
<span {...getStyles('label')}>{children}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ export function Usage() {
);
}

export function Disabled() {
return (
<div style={{ padding: 40 }}>
<TagsInput
disabled
label="disabled"
defaultValue={['React', 'Angular']}
placeholder="Enter tags"
/>
<fieldset disabled>
<TagsInput
label="disabled fieldset"
defaultValue={['React', 'Angular']}
placeholder="Enter tags"
/>
</fieldset>
</div>
);
}

export function Clearable() {
return (
<div style={{ padding: 40 }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export const TagsInput = factory<TagsInputFactory>((_props, ref) => {
onRemove?.(item);
}}
unstyled={unstyled}
disabled={disabled}
{...getStyles('pill')}
>
{item}
Expand Down

0 comments on commit dc5ed3d

Please sign in to comment.